Please answer the Data Structure Questions

User Generated

Qcncncn

Programming

Cpp data structures

University of New Haven

Description

Please answer each question in the attached file according to the requirements in the questions. Please write the explanation of the all the questions.

Unformatted Attachment Preview

Data Structures Midterm Review Topics covered include: C++ programming Object Oriented Programming Abstract Data types Big O Linked Lists Arrays Implementation issues Stacks Queues Double Ended Queues Recursion Basic sorting methods: Selection, transposition, insertion, bubble, shaker Advanced sorting methods: Quick, heap, merge, Radix, Shell 1) A) Assume that you have only two operations, push and pop. Push gets its input from the input stream, and pop sends its output to the output stream. Assume further the input stream consists of only three items, a,b,c, only in that order. For each permutation (out of 6) of a,b,c, either give correct commands to generate that sequence as output, or mark that sequence as impossible. I have solved one of them as an example. Ordering: Commands to achieve this output: 1.a,b,c push,pop,push,pop,push,pop 2. 3. 4. 5. 6. B) Assume that you have only the operations, enq, deq, and bypass. Enq gets its input from the input stream, and deq sends its output to the output stream. Bypass transfers an item directly from input stream to output stream. Assume further the input stream consists of only three items, a,b,c. For each permutation (out of 6) a,b,c, either give correct commands to generate that sequence as output, or mark that sequence as impossible. I have solved one of them as an example. Ordering: Commands to achieve this output: 1.a,b,c bypass,bypass,bypass 2. 3. 4. 5. 6. If you care, here are some powers of 2: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 2) In each case, give a NUMERIC ESTIMATE (I want an integer!) of how many operations it would take MINIMUM to do: [some specified sorting operation] 3) Given the following situations, how would you put the data in the desired order? Why did you choose the method you used? [some situation where a sort is needed] 4) I ran several different sorting methods on my computer. The process was interrupted. Given the unsorted data, and partially sorted data, which sorting algorithm was in process? 5) a) Write pseudo code for a program to insert one new item in a list in an array. (The list is already in order, and the item should be inserted in its proper place in that order.) You are given the array (call it TABLE) and the number of items already in the list, N. Your algorithm does NOT need to be efficient (I am expecting O(n) for this one). b) Describe in about one sentence how your algorithm could be used to sort an unsorted list. c) Describe in about one sentence how your algorithm could be used to build a priority queue. 6) Give the output, given matchup is called first with: name1=”tookey” name2=”tolkien” and then it is called with: name1=”jones” name2=”johnson” char matchup(char name1[100], char name2[100]) { int item; for (item=0; ((name1[item]!='\0') && //\0 used to mark end of string (name2[item]!='\0') && (item
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Hey hope everything is explained and answered. Please feel free to write for any queries. I'll be happy to help. Thanks. :)

1) A. Only two operations are available: push and pop.
Push gets its input from the input stream, and pop sends its
output to the output stream.
The input stream consists of only three items, a, b, c, only in
that order.
Ordering: Commands to achieve this output:
1. a, b, c
push, pop, push, pop, push, pop
2. a, c, b

push, pop, push, push, pop, pop

3. b, c, a

push, push, pop, push, pop, pop

4. b, a, c

push, push, pop, pop, push, pop

5. c, a, b

IMPOSSIBLE

6. c, b, a

push, push, push, pop, pop, pop

Explanation: A stack is a LIFO mode of data structure, so
keeping that in mind these are the possible sequences in order
to get the defined permutations of output.
B. Only three operations: enq, deq, and bypass.
Enq gets its input from the input stream, and deq sends its
output to the output stream. Bypass transfers an item directly
from input stream to output stream.
The input stream consists of only three items, a, b, c, only in
that order.
Ordering: Commands to achieve this output:
1. a, b, c
bypass, bypass, bypass
2. a, c, b
bypass, enq, bypass, deq
3. b, c, a
enq, bypass, bypass, deq
4. b, a, c
enq, bypas...


Anonymous
Nice! Really impressed with the quality.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags