Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Inserting an item in array and in linked list. 5. (24%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6};

image text in transcribed

Inserting an item in array and in linked list. 5. (24%) Suppose we have an array int a [8] = {1, 2, 3, 5, 6}; and we also have a linked list L of 5 entries 1 -> 2 -> 3 -> 5 -> 6, where 1 is the first in the linked list L, followed by 2 etc. We want to put a new item 4 between 3 and 5 in the array a and in the linked list L (a) Explain in plain English how you do that in the array a. You may have to shift items right (or left?) Do you use a loop like a for loop? You can write some C/C+ + / C# / Java code etc. to convince me, but the code does not have to run. (b) Explain in plain English how you do that in the linked list L. How do you change the link from 3 to 5 in the original list L? You can write some code or pseudo code to convince me. (c) What kind of problem may we have if the array is int a [5] = { 1, 2, 3, 5, 6} and we want to insert an item 4 between 3 and 5. Is this possible? What kind of changes may be needed? Does the same problem happen if we want to do this insertion of 4 between 3 and 5 in a linked list L of 5 entries 1 -> 2 -> 3 -> 5 -> 6

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

Step: 3

blur-text-image

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

Developing and delivering learning that is integrated with the job.

Answered: 1 week ago

Question

Use of assessments to determine trainees learning styles.

Answered: 1 week ago

Question

7. Discuss the advantages of embedded learning.

Answered: 1 week ago