Department of Computer Eng. & IT Amirkabir University of Technology (Tehran Polytechnic) Data Structures Lecturer: Abbas Sarraf 10 Questions on Linked Lists
Dept. of Computer Eng. & IT, Amirkabir University of Technology 1 Write efficient code to reverse the order of the contents of a singly linked list. Give the Big-Oh notation for the algorithm
Dept. of Computer Eng. & IT, Amirkabir University of Technology 2 Explain two different linked list variations (from a simply singly linked list), and list a positive and negative factor for each variation.
Dept. of Computer Eng. & IT, Amirkabir University of Technology 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: myTail myHead next data
Dept. of Computer Eng. & IT, Amirkabir University of Technology Notes: all data pointers that are not shown are pointing to non-Node objects or are nul l. Write a method that determines the distance (number of links) from the head n ode 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 th e structure.
Dept. of Computer Eng. & IT, Amirkabir University of Technology 4 The following function is supposed to return the length of a linked list. What is wrong?
Dept. of Computer Eng. & IT, Amirkabir University of Technology 5 The following function is supposed to recursively return the length of a linked list. What is wrong?
Dept. of Computer Eng. & IT, Amirkabir University of Technology 6 The following function is supposed to merge two linked lists. What is wrong?
Dept. of Computer Eng. & IT, Amirkabir University of Technology 7 The following function is supposed to print a Circular linked list. What is wrong?
Dept. of Computer Eng. & IT, Amirkabir University of Technology 8 The following function is supposed to insert a node in an ordered Circular linked list. What is wrong?
Dept. of Computer Eng. & IT, Amirkabir University of Technology 9 The following function is supposed to delete a node in an ordered Circular linked list. What is wrong?
Dept. of Computer Eng. & IT, Amirkabir University of Technology 10 با توجه به ليست داده شده در زير، خروجي هر يك از شبه كدهاي زير را مشخص كنيد. node *what(node *p) { if (p && p->link) return what(p->link->link); else return p; } node *q=what(first); cout data; void what(node *p) { if (p&& p->link) { what(p->link->link); cout data; what(p->link->link); } what(first);