Posted: June 7th, 2015

COIS 2020H S61 2015 Assignment 2.

COIS 2020H S61 2015 Assignment 2.

As with assignment 1, your assignment should be completed in C# using visual studio
You should zip up your assignment files (feel free to give me the full solution directories) into your username.zip (or rar) and submit on blackboard.
1.    A) Create a doubly linked list and populate it with 100 elements.  These elements represent NPC’s in a game, they should have an ID and a position (x, y).  They exist in a grid that is 32×32 (0,0 to 31, 31), and they should be generated at a random location.  The ‘player’ should start at position 15,15.  Run your program in a loop.  Every iteration through the loop the player moves one unit in any direction, and the NPC’s move one unit in any direction.  Take into account walls etc.

B) At each iteration find all the elements within a distance of 10 of the player.  Time how long this takes.

C) At each iteration of the list sort it based on the distance from the player (you can either make a new list each time, or do an in place sort), then read in all of the elements within a distance of 10 from the player.

D)  Which is faster B or C?  Which scales better/worse, with more elements or an increasing grid size? It’s up to you to decide how many iterations and how much testing you want to do to answer these questions.

2.    A)  Write a recursive function that reverses the order of a doubly linked list (you can use the same doubly linked list from Question 1, and the text has source code for a doubly linked list).

B)  Load up two doubly linked lists with 200 million identical small integer elements (say 0 – 15).  Calculate the sum.  Compare the timing for treating one list as a stack, and the other as a queue.  (Destroy each element as you process it; that’s why you need two lists).

3.    A) Create a Binary tree with 20 million elements. It should be (nearly) complete and balanced.

B) Traverse the tree in inorder using recursion, time it.

C) Traverse the tree using breadth first (which is not in order), time it.

D) Compare the timing of B and C.

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Live Chat+1-631-333-0101EmailWhatsApp