Question

Q.(1)Describe the algorithm and java implementation for the following operations A. Create a singly linked list...

Q.(1)Describe the algorithm and java implementation for the following operations

A. Create a singly linked list L1 with 4 nodes. You can use insert operation to add nodes to the list. Each element represent an airport code (e.g. BOS, ATL, JFK, MSP, etc.). Display the list L1 after it is created.

B. Given singly linked list L1, create another singly linked list L2 that contains the same elements but in the reverse order. Display the content of both L1 and L2.

C. Create a third list L3 with 4 nodes. Concatenate two singly linked lists L1 and L3, into a single list M that contains all nodes of L1 followed by all the nodes of L3. Display the content of L1, L3 and M.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Computer science emphasizes two important topics: datastructures and algorithms. Those topics are important because the choicAn example of the inere relationship betwen memary usage and CPU time involves the one-dimensional array and doubly-linked liDatastructure and algorithm basics Before we explore specific datastructures and algorithms, we need to examine three basic qcapabilities for storing and retrieving data items. Examples of container datastructures: arrays, linked lists, stacks, and qAlgorithm representation source code. However, writing source code before you fully understand an algorithm often leads to diLogic flow (for iteration and other purp oses) Terininal What does a flowchart look like? Suppose you have a simple algorithmRead ch No No Yes Yes cmint- Print. cmnt Figure 3. A flowchart for counting digit characters. Click on thumbnail to view fullBecause flowcharts are tools of the structured programming era, they arent as usetul in an object oriented content The UnifheEach element occupies the same number of bytes; the exact number depends on the type of the elements data item o All elementThe simplest kind of array has one dimension: each element associates with a single index. Java provides three techniques forSpecifies keyword new, followed by type, followed by integer_expression between square brackets (I ]), which identifies the nint [1 test_scores declares a one-dimensional array variable (test_scores) along with that variables type (int [1). The intPrimitive type one-dimensional arrays store data items that are primitive values. In contrast, reference type one-dimensionaltype variable_name [ new type initializer type variable_name new type initializer where initializer has the follow

Add a comment
Know the answer?
Add Answer to:
Q.(1)Describe the algorithm and java implementation for the following operations A. Create a singly linked list...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please do this in Java!!! Describe a method for performing a card shuffle of a singly...

    Please do this in Java!!! Describe a method for performing a card shuffle of a singly linked list of 2n elements, by converting it into two lists. A card shuffle is a permutation where a list L is cut into two lists, L1 and L2, where L1 is the first half of L and L2 is the second half of L, and then these two lists are merged into one by taking the first element in L1, then the first...

  • In JAVA, please. THANK YOU In this project you will create a generic linked list using...

    In JAVA, please. THANK YOU In this project you will create a generic linked list using Java Generics. Description: Create a generic class called GenLinkedList. GenLinkedList will use nodes that store a value of the generic type to store its contents. It should have the following methods. The methods should all operate on the object making the call (none are static). Perform checking of the parameters and throw exceptions where appropriate. The linked list should be singly-linked. It should not...

  • C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you...

    C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you to extend the interface of a list to have these member functions as well. struct ListNode { int element; ListNode *next; } Write a function to concatenate two linked lists. Given lists l1 = (2, 3, 1)and l2 = (4, 5), after return from l1.concatenate(l2)the list l1should be changed to be l1 = (2, 3, 1, 4, 5). Your function should not change l2and...

  • C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you to extend the interface of...

    C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you to extend the interface of a list to have these member functions as well. struct ListNode { int element; ListNode *next; } Write a function to concatenate two linked lists. Given lists l1 = (2, 3, 1)and l2 = (4, 5), after return from l1.concatenate(l2)the list l1should be changed to be l1 = (2, 3, 1, 4, 5). Your function should not change l2and...

  • Title: Implementation of chained hashing in Java or Python Description: Implement a double linked list with...

    Title: Implementation of chained hashing in Java or Python Description: Implement a double linked list with a procedure for adding list elements. Implement a hash table using chaining and the linked list discussed above. Use Array size m = 7 A hash function of: h = k mod 7 Insert 100 random key values into the table. Key values should be between 0 and 99. Implement a Search procedure that tells whether a particular key value is in the hash...

  • 1. Create a class MLL, a singly linked, non-circular list where each node only has one...

    1. Create a class MLL, a singly linked, non-circular list where each node only has one link next and the list has a head and a tail link (think about implementation of node). The MLL class also implements the Iterable interface. The following should be implemented as well: 2. Add the methods to the MLL class: a. iterator() to implement the Iterable interface. This method returns an instance of MLLI initialized appropriately. b. addFirst( value) that adds a value to...

  • Pull out question 8 on Exercises. See also: Program 4.16 invert (), Program 4.4 printList () Configuring -main () 1. Create a linked list 2. Function call of 8 (a) and (b) 3. Check the accuracy of th...

    Pull out question 8 on Exercises. See also: Program 4.16 invert (), Program 4.4 printList () Configuring -main () 1. Create a linked list 2. Function call of 8 (a) and (b) 3. Check the accuracy of the output of r list and l list 4. Repeat steps 1-3 above Please use c language void printlist(listPointer first) printf ("The list contains: ) for (; first; first = first→link) printf ("%4d", first-"data); printf("In") Program 4.4: Printing a list the nodes are...

  • Assignment #2: List - Array Implementation Review pages 6-7 in "From Java to C++" notes. Due...

    Assignment #2: List - Array Implementation Review pages 6-7 in "From Java to C++" notes. Due Friday, February 9th, 2017 @ 11:59PM EST Directions Create a List object. Using the following definition (List.h file is also in the repository for your convenience) for a list, implement the member functions (methods) for the List class and store the implementation in a file called List.cpp. Use an array to implement the list. Write the client code (the main method and other non-class...

  • 8.9 Coding lab #5: create a dynamic array ADT and a singly linked list ADT. Honor Code...

    8.9 Coding lab #5: create a dynamic array ADT and a singly linked list ADT. Honor Code Your answers to this homework must be your own work.You are not allowed to share your solutions.You may not engage in any other activities that will dishonestly improve your results or dishonestly improve or damage the results of others. Plagiarism Plagiarism is when you copy words, ideas, or any other materials from another source without giving credit. Plagiarism is unacceptable in any academic environment....

  • Part 1: Implement a singly linked list -------------------------------------- (a) Your job is to implement a generic...

    Part 1: Implement a singly linked list -------------------------------------- (a) Your job is to implement a generic singly linked list that can hold any data type. The interface has been specified and provided to you in a header file called mylist.h. So your job is to write mylist.c that implements each function whose prototype is included in mylist.h. Specifically, you are asked to write the following functions: struct Node *addFront(struct List *list, void *data) void traverseList(struct List *list, void (*f)(void *))...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT