Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem One: (25 points. 4 points each for first five questions. 5 points for question 6) You textbook listed common functionality that a list should

Problem One: (25 points. 4 points each for first five questions. 5 points for question 6) You textbook listed common functionality that a list should have (refer to Table 2.1.2). However, your book only implemented algorithm for insertAfter and remove. In this problem, you are asking to implement the rest common functionality in table 2.1.2.

  1. append: which append the given node after the tail of the list
  2. prepend: which insert the given node to the front of the head of the list
  3. printList: which print all node data in order as their node in the list
  4. sort: Sort the list items in ascend order
  5. isEmpty: Return true if the list is empty; false otherwise
  6. For printListReversely functionality, if the list is a single linked list, we cannot step through the list reversely. How would you implement this printListReversely algorithm?

Problem Two: (15 points, 5 points each) In problem one, we didnt implement getLength function. This function has some challenge.

  1. For getLength function, one implement is that we can step through the list, from head to tail, and count. Write algorithm for this implementation
  2. In previous implementation, what is the run time?
  3. If I want constant run time for getLength function, what change needs to be made for List data structure? How this change will affect the implementation of other functions such as insertAfter and remove?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genomes Browsers And Databases Data Mining Tools For Integrated Genomic Databases

Authors: Peter Schattner

1st Edition

0521711320, 978-0521711326

More Books

Students also viewed these Databases questions

Question

Why is the statement of cash flows a useful document?

Answered: 1 week ago

Question

Address an envelope properly.

Answered: 1 week ago

Question

Discuss guidelines for ethical business communication.

Answered: 1 week ago