1 / 12

10 Questions on Linked Lists

10 Questions on Linked Lists. 1. Write efficient code to reverse the order of the contents of a singly linked list. Give the Big-Oh notation for the algorithm. 2.

croxton
Télécharger la présentation

10 Questions on Linked Lists

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 10 Questions on Linked Lists

  2. 1 • Write efficient code to reverse the order of the contents of a singly linked list. Give the Big-Oh notation for the algorithm

  3. 2 • Explain two different linked list variations (from a simply singly linked list), and list a positive and negative factor for each variation.

  4. myHead next data myTail 3 • Crazy lists. Someone has written a class that creates CrazyLists. These are linked lists made up of singly linked nodes. But instead of making a nice sequential list, the class creates crazy linked structure. Some nodes data field point to other nodes instead of data. This leads to a branching structure that could look like this:

  5. Notes: • all data pointers that are not shown are pointing to non-Node objects or are null. • Write a method that determines the distance (number of links) from the head node to the tail node. • the tail node could be pointing at ANY of the nodes in the structure • There will be only one path from myHead to myTail • the Crazy list will not contain cycles, circular references that create loops in the structure.

  6. 4 • The following function is supposed to return the length of a linked list. What is wrong?

  7. 5 • The following function is supposed to recursively return the length of a linked list. What is wrong?

  8. 6 • The following function is supposed to merge two linked lists. What is wrong?

  9. 7 • The following function is supposed to print a Circular linked list. What is wrong?

  10. 8 • The following function is supposed to insert a node in an ordered Circular linked list. What is wrong?

  11. 9 • The following function is supposed to delete a node in an ordered Circular linked list. What is wrong?

  12. 10 • با توجه به ليست داده شده در زير، خروجي هر يك از شبه كدهاي زير را مشخص كنيد. void what(node *p) { if (p&& p->link) { what(p->link->link); cout<<p->data; what(p->link->link); } } what(first); node *what(node *p) { if (p && p->link) return what(p->link->link); else return p; } node *q=what(first); cout<<q->data;

More Related