Showing 5-8 out of 8
CS1121400.doc-Computer Science Foundation Exam Dec...
CS1121400.doc-Computer Science Foundation Exam December 14,
CS1121400.doc-Computer Science Foun...
CS1121400.doc-Computer Science Foundation Exam December 14,
Page 5
Computer Science Foundation Exam
December 14, 2000
Section I B
No Calculators!
Name:
_______________________________
SSN:
________________________________
In this section of the exam, there are three (3) problems.
You must do all of them.
The weight of each problem in this section is indicated with the problem.
The algorithms in this exam are written in a combination of pseudocode, and
programming language notation.
Any algorithms that you are asked to
produce should use a syntax that is clear and unambiguous.
Partial credit can not be given unless all work is shown.
As always, be complete, yet concise, and above all be neat
,
credit can not be given when your results are unreadable.
Page 6
(4, 10%)
Assume that a global array of characters, called
X
, exists and includes locations
that
range from
1
to
n
.
In the space below, write a
recursive
procedure, called
Reverse
, that
exactly reverses the order of the characters in the array.
You may assume that the array is already populated with alphabetic characters before the
procedure is initially called and you should only write the code contained in
Reverse
.
You may also assume that the procedure will initially be called as follows:
Reverse(1, n).
You may use pseudocode or C or Pascal syntax but points will be
taken off if your meaning is not clear.
procedure Reverse(i, j : integer)
4
Page 7
(5, 18%)
Find the closed form or exact value for the following:
( n is an arbitrary positive integer):
a)
60
0
)
3
5
(
i
i
=
_______________________
b)
1
2
1
)
1
4
(
k
i
i
=
____________________
c)
90
40
)
2
3
(
i
i
=
_____________________
5
Page 8
(6, 18%)
Given the following Binary Tree, answer the questions below :
a)
Is this a valid Binary Search Tree? (circle one)
Yes
No
b)
List the nodes of this tree in the order that they are visited in a
preorder
traversal:
______
______
______
______
______
______
______
______
c)
Perform the following procedure on the tree above, listing the output in the spaces below and
leaving any unused spaces blank.
Assume that the procedure is initially called with
P6(root)
and that the tree nodes and pointers are defined as:
tree_node definesa record
data isoftype Num
left, right isoftype ptr toa tree_node
endrecord
tree_ptr isoftype ptr toa tree_node
procedure P6(node_ptr isoftype in tree_ptr)
if (node_ptr <> NULL) then
P6(node_ptr^.right)
print(node_ptr^.data)
P6(node_ptr^.left)
endif
endif
endprocedure
______
______
______
_______
______
______
_______
______
19
13
11
16
25
27
22
7
6
Ace your assessments! Get Better Grades
Browse thousands of Study Materials & Solutions from your Favorite Schools
University of Pune
University_of_Pune
School:
Computer_Science_I
Course:
Introducing Study Plan
Using AI Tools to Help you understand and remember your course concepts better and faster than any other resource.
Find the best videos to learn every concept in that course from Youtube and Tiktok without searching.
Save All Relavent Videos & Materials and access anytime and anywhere
Prepare Smart and Guarantee better grades
Students also viewed documents
lab 18.docx
lab_18.docx
Course
Course
3
Module5QuizSTA2023.d...
Module5QuizSTA2023.docx.docx
Course
Course
10
Week 7 Test Math302....
Week_7_Test_Math302.docx.docx
Course
Course
30
Chapter 1 Assigment ...
Chapter_1_Assigment_Questions.docx.docx
Course
Course
5
Week 4 tests.docx.do...
Week_4_tests.docx.docx
Course
Course
23
Week 6 tests.docx.do...
Week_6_tests.docx.docx
Course
Course
106