Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data structure and Algorithm no information A.6 B.) Section 2. In this section there are 6 short questions, if you answer each question correctly, you

Data structure and Algorithm image text in transcribed
image text in transcribed
image text in transcribed
no information
A.6 B.) Section 2. In this section there are 6 short questions, if you answer each question correctly, you are given 5 marks. 30 mark in total for this section. Q1. Based on InsertList algorithm in the lecture, someone want to create a seq list by the following function. Suppose before calling this function, L is already initialized. typedef struct { int elem[50]; int len; } SeqList; // Insert a new element into the List at the Position, l/the position is logic-based,start from 1. int InsertList(SeqList *L, int pos,DataType e) { // ignore, uncorrelated to the question } void CreateList(SeqList *L) {InsertList(L,1,3); Insert List(L,3,18); InsertList(L,-3,16); Insert List(L,1,2); InsertList(L,2,5); } Show the element arrangement after finishing.(just fill in the rectange with number). 0 1 2 3 4 5 6 7 8 9 10 11 12 L Q2. If we run the following program, please write out the output of it. int main( { SeqStack s; int x; InitStack(&s); for(i=10;i>5;i-=2) Push(&s,2*i+1); while(!IsEmpty(&s)) { Pop(&s,&x); printf("%d ",x); } The Output is : Q3: Create a AVL tree from input sequence of {8,10,12,18,6,4,3,20,23,35).( tips, if you can not draw the graph easily, you can draw it on paper, and write down its PreOrder , InOrder, traverse sequence here) 3 06 0 2 3 InOrder: PreOrder: A.6 B.) Section 2. In this section there are 6 short questions, if you answer each question correctly, you are given 5 marks. 30 mark in total for this section. Q1. Based on InsertList algorithm in the lecture, someone want to create a seq list by the following function. Suppose before calling this function, L is already initialized. typedef struct { int elem[50]; int len; } SeqList; // Insert a new element into the List at the Position, l/the position is logic-based,start from 1. int InsertList(SeqList *L, int pos,DataType e) { // ignore, uncorrelated to the question } void CreateList(SeqList *L) {InsertList(L,1,3); Insert List(L,3,18); InsertList(L,-3,16); Insert List(L,1,2); InsertList(L,2,5); } Show the element arrangement after finishing.(just fill in the rectange with number). 0 1 2 3 4 5 6 7 8 9 10 11 12 L Q2. If we run the following program, please write out the output of it. int main( { SeqStack s; int x; InitStack(&s); for(i=10;i>5;i-=2) Push(&s,2*i+1); while(!IsEmpty(&s)) { Pop(&s,&x); printf("%d ",x); } The Output is : Q3: Create a AVL tree from input sequence of {8,10,12,18,6,4,3,20,23,35).( tips, if you can not draw the graph easily, you can draw it on paper, and write down its PreOrder , InOrder, traverse sequence here) 3 06 0 2 3 InOrder: PreOrder

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago