Draw a diagram of an empty circular queue and describe it to the reader.

Similar documents
MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

CS301 - Data Structures Glossary By

Code No: R Set No. 1

INSTITUTE OF AERONAUTICAL ENGINEERING

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

Data Structures Question Bank Multiple Choice

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours

17CS33:Data Structures Using C QUESTION BANK

Department of Computer Science and Technology

1. Stack overflow & underflow 2. Implementation: partially filled array & linked list 3. Applications: reverse string, backtracking

12 Abstract Data Types

CS8391-DATA STRUCTURES QUESTION BANK UNIT I

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

First Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Prepared By: Ms. Nidhi Solanki (Assist. Prof.) Page 1

CS8391-DATA STRUCTURES

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK

TREES. Trees - Introduction

Table of Contents. Chapter 1: Introduction to Data Structures... 1

GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING (07) / INFORMATION TECHNOLOGY (16) / INFORMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

CS 8391 DATA STRUCTURES

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

PESIT Bangalore South Campus Department of MCA Course Information for

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

Binary Trees, Binary Search Trees

7.1 Introduction. A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w

University of Palestine. Final Exam 2 nd semester 2014/2015 Total Grade: 50

CS 216 Exam 1 Fall SOLUTION

Chapter 4 Trees. Theorem A graph G has a spanning tree if and only if G is connected.

1. Attempt any three of the following: 15

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Course Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU

CS61B Lecture #20: Trees. Last modified: Wed Oct 12 12:49: CS61B: Lecture #20 1

PA3 Design Specification

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

17 February Given an algorithm, compute its running time in terms of O, Ω, and Θ (if any). Usually the big-oh running time is enough.

Largest Online Community of VU Students

Trees! Ellen Walker! CPSC 201 Data Structures! Hiram College!

Summer Final Exam Review Session August 5, 2009

Lec 17 April 8. Topics: binary Trees expression trees. (Chapter 5 of text)

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

COMP 250 Fall binary trees Oct. 27, 2017

Binary Trees

EE 368. Week 6 (Notes)

An Introduction to Trees

Revision Statement while return growth rate asymptotic notation complexity Compare algorithms Linear search Binary search Preconditions: sorted,

Sample Question Paper

March 20/2003 Jayakanth Srinivasan,

CS61B Lecture #20: Trees. Last modified: Mon Oct 8 21:21: CS61B: Lecture #20 1

Course Review for Finals. Cpt S 223 Fall 2008

Lecture 26. Introduction to Trees. Trees

6-TREE. Tree: Directed Tree: A directed tree is an acyclic digraph which has one node called the root node

CSI33 Data Structures

Lecture Notes 16 - Trees CSS 501 Data Structures and Object-Oriented Programming Professor Clark F. Olson

Visit ::: Original Website For Placement Papers. ::: Data Structure

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

DS ata Structures Aptitude

Tree. A path is a connected sequence of edges. A tree topology is acyclic there is no loop.

CE 221 Data Structures and Algorithms

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I TWO MARKS UNIT I- 2 MARKS

Stacks, Queues and Hierarchical Collections

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

Introduction to Computers and Programming. Concept Question

INF2220: algorithms and data structures Series 1

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

CS61B Lecture #20. Today: Trees. Readings for Today: Data Structures, Chapter 5. Readings for Next Topic: Data Structures, Chapter 6

VALLIAMMAI ENGINEERING COLLEGE

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

Basic Data Structures (Version 7) Name:

Data Structures. Chapter 06. 3/10/2016 Md. Golam Moazzam, Dept. of CSE, JU

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113)

Total No. of Questions :09] [Total No. of Pages : 02. II/IV B.Tech. DEGREE EXAMINATIONS, NOV/DEC First Semester CSE/IT DATA STRUCTURES USING C

Fundamentals of Data Structure

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING ECE ALGORITHMS AND DATA STRUCTURES Total:

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

CS 445: Data Structures Final Examination: Study Guide

CS302 Data Structures using C++

Computer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY

CSE 373 Spring Midterm. Friday April 21st

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Data Structure. IBPS SO (IT- Officer) Exam 2017

MLR Institute of Technology

Stacks, Queues and Hierarchical Collections. 2501ICT Logan

Trees. (Trees) Data Structures and Programming Spring / 28

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Data Structure (CS301)

Section Summary. Introduction to Trees Rooted Trees Trees as Models Properties of Trees

I Year MCA I Semester L T P To C FOUNDATIONS OF INFORMATION TECHNOLOGY

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

Upcoming ACM Events Linux Crash Course Date: Time: Location: Weekly Crack the Coding Interview Date:

Transcription:

1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 1 1983/84 COSC1020/30 Tests >>> The following was given to students. >>> Students can have a good idea of test questions by examining and trying the questions in the text book. Most test questions will either (1) come directly from the texts, (2) be based on the reports, (3) be based on class lectures, or, be variations of such questions. Without limiting the types of questions to be asked, students can expect questions of the following types. In brief, consider all concepts and terminolgy used in the text book, reports, and lectures and ask the typical questions - how, why, when, where and what - individually and in combination. 1. Definition. What does a technical term mean. E.g. What is a compiler? Define what is meant by computable. What does the term recursion mean? Give a definition for an abstract data type. Such questions can involve any of the terms in the textbooks and Pascal manuals. 2. Example. Give examples illustrating particular concepts. E.g. Give an example showing that arithmetic on real numbers is not commutative. Draw a diagram of an empty circular queue and describe it to the reader. 3. Tracing. Play at being a computer to show what happens within a program at execution time. E.g. Given the listing of a program show what the values of some variables are after 5 iterations of the loop. What is the final result? 4. Program. Write either complete or fragments of programs which solve standard problems, or illustrate particular programming concepts. E.g. Write a program to find the maximum of three integers. Write a program fragment to insert a node in a doubly linked list. Write a procedure to swap the top two elements on a stack. 5. Analysis. Compare and contrast algorithms and concepts. E.g. Distinguish between a compiler and an interpreter. Under what circumstances can a binary search be used? Compare the efficency of insertion sort and quicksort? Can quicksort and merge sort be used equally effectively on files? Explain your answer. Which algorithm of A or B takes more time to execute? more space? 6. Describe concepts and methods. E.g. Describe top down design. Describe what big O notation is. Why we use it? When do we use it?

1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 2 The following questions and problems have been given on previous tests. This list should give you a better idea of what to expect on future tests. You will have to examine each question and decide if the coresponding topic is addressed in this course. The questions are a subset of test questions used over the previous 20 years, not all topics are covered in any particular year. 1. Assume that real numbers are represented by: (1) a +/- sign for the number; (2) 3 decimal digits for the mantissa (fraction part); and, (3) 2 decimal digits for the exponent, using excess 50 to represent positive and negative exponents. In each part below give examples of two real non zero numbers A and B representable in the above system which show the statement to be TRUE. 1a) A + B = A 1b) A+B underflows 1c) Sum of A copies of 1/A is not equal to 1. A must be positive. 1d) (X+Y) + Z <> (X+Z) + Y 1e) A * (1/A) <> 1 1f) A+B overflows 2a) Draw a syntax diagram of the Pascal xxx statement. 2b) Give a BNF definition of the Pascal xxx statement. Where xxx is any of the statement types in Pascal. For example, CASE, FOR, WHILE, REPEAT...UNTIL, etc. 3. Describe the semantics of the statement in Question 2. 4. Study the following logic frames for a Pascal program. No additional declarations of variables of any type are to be made. PROGRAM FOUR (INPUT, OUTPUT) ; {Logic Frame 1} VAR A : INTEGER ; PROCEDURE ONE ; VAR B : REAL ; BEGIN... END {ONE} PROCEDURE TWO ; VAR C : REAL ; PROCEDURE THREE ; VAR D : INTEGER ; BEGIN... END {THREE} BEGIN... END {TWO} BEGIN... END {FOUR} PROGRAM ONE (INPUT, OUTPUT) ; {Logic Frame 2} VAR A : INTEGER ; PROCEDURE THREE ; VAR B : REAL ; PROCEDURE FOUR ; VAR D : INTEGER ; BEGIN... END {FOUR}

1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 3 BEGIN... END {THREE} PROCEDURE TWO ; VAR C : REAL ; BEGIN... END {TWO} BEGIN... END {ONE} For the programs and procedures named on the first line below, list all identifiers satisfying the criteria specified on the left. ONE TWO THREE FOUR Local Identifiers Global Identifiers Referencable Variables Referencable Procedures 5a) Explain the meaning of the terms CALL BY VALUE, CALL BY ADDRESS, and CALL BY NAME. 5b) In the example programs given below: What is the value printed for X under CALL BY VALUE? What is the value printed for X under CALL by ADDRESS? MAIN PROGRAM - 1 MAIN PROGRAM - 2 X := 2 ; Y := 4 ; A := 6 A := 2 ; Y := 4 ; X := 6 testcase ( X, A+X, Y, Y ) testcase ( Y, A+X, Y, X ) print X print X END END SUBPROGRAM - 1 SUBPROGRAM - 2 testcase ( A, B, X, Y ) testcase ( X, B, Y, A ) Y := A + Y - B Y := A + Y - B A := X * Y A := X * Y END END 6. What is the definition of an abstract data type? 7. Describe three different Pascal data types from the perspective of abstract data types. 8. Describe what the PCL command in the Computer Science VAX operating system does. 9. Classify and describe in English, including examples of type declarations, the Pascal data types covered to date.

1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 4 10. Explain what is meant by side effects. Give an example which shows why side effects should be avoided. 11. Explain what is meant by recursive programming. Give an example of a recursive subprogram in Pascal and describe with comments what the program is doing. 12. Describe sequential files in Pascal as an abstract data type. 13. Describe the components of a structured Pascal program. Consider all the different aspects of a program from the top down. Cover each aspect to about the same level of detail. 14. Describe a typical structure of a recursive program. 15. Describe the set of appropriateness questions which a programmer should consider in the decomposition of a program into the standard components: sequence, decision, loop. 16. Describe a general template (logic frame) showing how a programmer would handle the input of data from sequential files. 17. For mathematical algorithms dealing with real numbers define and describe: a) roundoff errors d) overflow b) truncation errors e) underflow c) representation errors 18. Describe the syntax and semantics of syntax diagrams, include an example. 19. Contrast the use of the REPEAT Statement with that of the WHILE statement 20. Describe the main features of block structuring in a programming language such as Pascal (Consider the scope of variables). 21a. Define and describe in general terms what is an Abstract Data Type. b. Why is an Abstract Data Type a useful concept? 22. Describe with an annotated Pascal program the input and output processing of text files. 23a. In Pascal what is a pointer type? b. Why are pointers useful in a programming language? c. What operations can and cannot be performed with pointer variables in Pascal. 24a. Describe the types of subprograms in Pascal. b. Describe the linkage between formal and actual parameters in Pascal. 25. The following two algorithms both describe how to behave when approaching traffic signals. {From Goldschlager p68.}

1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 5 IF signal is working THEN IF signal is red or signal is amber THEN stop ELSE proceed IF signal is working THEN IF signal is red or signal is amber THEN stop ELSE proceed In what circumstances do the algorithms describe different behaviour? Which algorithm do you consider the more satisfactory? 26. Write Pascal expressions using ORD and CHR functions to duplicate the effects of PRED and SUCC with CHAR arguments. Include descriptive and explanatory comments. {From Cooper p52.} 27. Write a segment of Pascal code to reverse the case (change lower case to upper case, and upper case to lower case) for all of the alphabetic characters in word (defined below). Include descriptive and explanatory comments. Assume the following have been defined: ; VAR word : PACKED ARRAY [1..max] OF CHAR wi : 1..max {Index to the characters in word.} 28. Explain what is meant by the notation O( f(n) ) when referring to the time or space requirements of an algorithm. 29. If an algorithm requires a time T(n) = O(2*n) to execute, show that T(n) = O(n). 30. Demonstrate that if an algorithm consists of two sequential steps A ::= A1 ; A2 and if the time to do A1 is T(n) = O(n**2) and the time to do A2 is T(n) = (n log n), then the time to do A is T(n) = O(n**2). 31. What conditions must exist before a binary search algorithm can be used? 32. What conditions force one to use a linear search algorithm? 33. Demonstrate and describe why linear search is an O(n) algorithm and binary search is an O(n log n) algorithm. 34. Demonstrate why merge sort is considered to be an O(n log n) algorithm. How do its best and worst cases compare. 35. Demonstrate why quicksort is considered to be an O(n log n) algorithm. How do its best and worst cases compare. Explain. 36. Quicksort requires the use of a stack to remember which partitions remain to be sorted. How can one ensure that the stack will not require more

1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 6 than (log n) entries? 37. Describe under what conditions one would use an O(n**2) sorting algorithm when O(n log n) algorithms are in general considered to be faster. 38. Given a list of n numbers and a pivot value, pv, show with a series of annotated diagrams how the partition algorithm in quicksort does its work. 39. Describe, and give examples, of what is meant by infix, postfix and prefix notations. 40. Describe with commented pseudo code how one converts from infix to (a) postfix, (b) prefix. 41. Describe with commented pseudo code how one converts from postfix (or prefix) to fully parenthesized infix notation. 42. Given a set of expressions in infix, postfix and prefix forms convert to the other two forms. 43. Compare and contrast the notions of compilation and interpretation. 44. Write commented program segments in Pascal for: stacks : array representation - push and pop operations. list representation queues : array representation - add and take operations. list representation dequeues : as for queues. singly linked lists and doubly linked lists insert new element delete an element 45. Compare and constrast the stack and queue data structures. When would they be used? 46. Under what circumstances is it preferable to use doubly linked lists instead of singly linked lists. 47. Described with annotated pseudo code the standard logic frame for a search algorithm. 48. Given a set of postfix (prefix) expressions with numeric operands, evaluate the expressions. QUESTIONS ON TREES 49. Give a definition of a binary tree.

1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 7 50. Describe a logic frame for tree traversal. 51. Describe what is meant by inorder, postorder and preorder traversal of a binary tree. 52. What is meant by the terms breadth first search, and depth first search? 53. Define what is meant by a sorted binary tree. 54. Describe a logic frame for searching a sorted binary tree. 55. Describe a logic frame for adding a new leaf node to a binary tree. 56. With respect to trees define the following terms: parent node, descedent node, ancestor node, sibling node, leaf node, root node, path, path length, depth, height, degree, general tree, n ary tree, binary tree, balanced tree. 57. Describe a general tree as an abstract data type. COMPUTBILITY 58. Explain what is the Church-Turing thesis? 59. Outline in general terms two methods which are used to show that some problems are impossible to solve. 60. What is the most important property that most unsolvable problems have in common? 61. Does the unsolvability of the halting problem mean that we should not try to show an algorithm halts? Explain. 62. Describe the general operation of a Turing machine. 63. Describe the general operation of a Markov algorithm. 64. If all computational models are equivalent, why do we have different models of computers? Explain. 65. Explain what is meant by the terms: computable, partially computable, not partially computable. QUESTIONS ON RECURSION THEOREM 66. What is the recursion theorem? Explain. 67. Given the following program segment (in pseudo-pascal) with all string variables. means concatenation. A := A B C ; B := DE F G ; C := CopyAndDoubleUpQuotesIn(A) ; D := CopyAndDoubleUpQuotesIn(B) ; E := A X Y B S T C D ; Execute the above statements. Show the contents of memory for each of A, B, C, D, E in the spaces below. Each box contains exactly one character. An empty box means blank.

1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 8 VAR LENGTH MEMORY A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 etc. QUESTIONS ON COMPLEXITY Note: questions 28, 29, 30 are also in this category. 68. Discuss how we measure time and space complexity of an algorithm. What are some of the difficulties we encounter in measuring complexity? How do we get around such difficulties? 69. What is meant by the complexity of a problem? Explain. 70. Describe how we determine the complexity of a problem. 71. Explain why for sequential machines the complexity of a problem must be of O(n) or greater. 72. Describe what we mean by polynomial time and exponential time algorithms. 73. Describe what we mean by the terms: P-problems, NP-problems. Why is this considered important in computer science? 74. Describe in general terms the various ways in which we attempt to reduce complexity of an algorithm. 75. Describe the basic structures of algorithms which have complexity measures of O(f(n)) where f(n) is: constant, (log n), n, n**c, 2**n, a**n, n**n. 76. Given the fundamental O(f(n)) complexity of an algorithm what can you deduce about the way in which the algorithm is structured and how much work it does. COSC1020/30 Test - Header Page Student Number: Surname: First Name(s):

1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 9 COSC1030.03 Introduction to Computer Science II Final Examination : April 10, 1984 Three hours : 3:30 pm to 6:30 pm Please circle the name of the instruction for your section. G. Gotshalks M. Shepherd 1. All questions are to be attempted. 2. This is a closed book test. 3. Values of the questions are indicated below: QUES MAX MARK 1 9 2 9 3 9 TOTAL RAW SCORE 4 9 5 9 LETTER GRADE 6 18 7 18 8 18 9 18 10 18 TOT 135