Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q4 25 pts) Implement Stack ADT as a Singly Linked List without using the insertAtIndex, deleteElement, readIndex functions of the Singly Listed List. That is,

image text in transcribed
Q4 25 pts) Implement Stack ADT as a Singly Linked List without using the insertAtIndex, deleteElement, readIndex functions of the Singly Listed List. That is, the push, pop and peek operations should not call insertAtIndex(0, data), deleteElement(0) and readIndex(0) functions. The push, pop and peek operations should be directly implemented to insert an element in the beginning of the linked list, to delete an element from the beginning of the linked list and to read the element value from the beginning of the linked list. To help you out, the implementation of the push function is given in the startup code provided. Your task is to implement the peek and pop functions like this without calling any other function. You can notice that the insertAtIndex, deleteElement and readIndex functions have been removed from the Stack class and you should not use them. After implementing the pop and peek functions, you will be comparing the actual run-time of the push and pop operations of a Stack implemented as a Singly Linked List (with insertions and deletions in the beginning of the Linked List) with that of a Stack implemented as a Doubly Linked List (with insertions and deletions at the tail/end of the Linked List). The main function provided to you has the timers setup for this purpose. Your task is to just run the main functions and measure the average time taken (in microseconds) for the push and pop operations with the Stack as a Singly Linked List and with the Stack as a Doubly Linked List for the following values of the parameters: (i) # elements to be pushed-1000. ICXX0. I 00000, 1000000; (ii) maximum! value for any element-50000 and (iii) # trials: 50 You need to include the following as part of your answer to this question (i) the code for the Singly Linked List-based implementation of the Stack class (ii) a table presenting the actual run-times for the parameters mentioned above (iii) snapshots of the actual run-times for the above cases (iv) interpretation of the difference/similarity in the actual run-times for the push and pop operations between the Singly Linked List and Doubly Linked List implementation of the Stack ADT

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

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions