Computers and Technology

(20p)Two linked lists (simple link, not double link) heads are given: headA, and headB; it is also given that the two lists intersect, thus after the intersection they have the same elements to the end. Find the rst common element, without modifying the lists elements or using additional datastructures. a) A linear algorithm is discussed in the lecture: count the lists rst, then use the count di erence as an o set in the longer list, before traversing the lists together. Write a formal pseudocode (the pseudocode in the lecture is vague), using \next" as a method/ pointer to advance to the next element in a list. b) Write the actual code in a programming language (C/C++, Java, Python etc) of your choice and run it on a made-up test pair of two lists. A good idea is to use pointers to represent the list linkage.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:40, mcfancei
Reading characters and strings from the keyboard: consider the following c++ program 1. #include 2. #include 3. using namespace std; 4. mystring1 5. 6. int main() 7. { 8. 9. string mystring1, mystring2; mychar1 10. 11. 12. char mychar1, mychar2; 13. 14. cout< < "enter a string: "; mychar2 15. 16. cin> > mystring1; // 17. cin. get(mychar1); 18. cin> > mychar2; 19. getline(cin, mystring2); mystring2 20. 21. 22. cout<
Answers: 1
image
Computers and Technology, 22.06.2019 06:50, wtfcmd
Match the personality traits with their description
Answers: 1
image
Computers and Technology, 22.06.2019 14:00, GGerardi7552
What are procedures that keep a data base current
Answers: 1
image
Computers and Technology, 23.06.2019 18:30, milkshakegrande101
Where can page numbers appear? check all that apply. in the header inside tables in the footer at the bottom of columns at the top of columns
Answers: 1
Do you know the correct answer?
(20p)Two linked lists (simple link, not double link) heads are given: headA, and headB; it is also g...

Questions in other subjects: