Final Exam Practice Problems — CS 112, Boston University
.pdf
keyboard_arrow_up
School
Boston University *
*We aren’t endorsed by this school
Course
112
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
14
Uploaded by andrewleenyk
12/17/23, 8:15 PM
Final Exam Practice Problems — CS 112, Boston University
https://www.cs.bu.edu/courses/cs112/final_practice.html
1/14
Final Exam Practice Problems
As we get closer to the exam, solutions will be posted under
Other Content
on Blackboard.
These problems are not
comprehensive, so make sure to review all of the relevant materials.
1. Which of the following data structures would be most appropriate for a program that
simulates the operation of an airport in order to determine the maximum delays
encountered by arriving and departing planes?
a. queue
b. binary tree
c. heap
d. stack
e. hash table
2. A stack s
of integers initially contains the following data from top to bottom:
The following code is then executed:
After this code has been executed, what are the contents of the stack?
a. {8, 10}
b. {10, 8}
c. {15, 3}
d. {10, 8, 6, 3}
e. none of the above
3. Suppose that items A, B, C, D and E are pushed, in that order, onto an initially empty stack
S. S is then popped four times; as each item is popped off, it is inserted into an initially
empty queue.
{6, 2, 7, 3}
int x = s.pop();
int y = s.pop();
int z = s.pop();
s.push(x + y);
int w = s.pop();
s.push(w + z);
12/17/23, 8:15 PM
Final Exam Practice Problems — CS 112, Boston University
https://www.cs.bu.edu/courses/cs112/final_practice.html
2/14
If two items are then removed from the queue, what is the next item that will be removed
from the queue?
a. item A
b. item B
c. item C
d. item D
e. item E
4. If the keys in the tree below are printed using a postorder traversal, what will the result be?
a. G E F A B C D
b. G E A B F C D
c. A E B G C F D
d. A E B C F D G
e. A B E C D F G
Questions 5 and 6
involve binary trees whose nodes have the following structure:
5. Consider the following method:
G
/ \
E F
/ \ / \ A B C D
public class Node {
public char val;
public Node left;
public Node right;
}
public static int mystery(Node root) {
if (root != null) {
if (root.left == null && root.right == null) {
return 0
;
}
int sum = mystery(root.left) + mystery(root.right);
if (sum == 0
) {
Node temp = root.left;
root.left = root.right;
12/17/23, 8:15 PM
Final Exam Practice Problems — CS 112, Boston University
https://www.cs.bu.edu/courses/cs112/final_practice.html
3/14
What does this method do to the tree whose root is referred to by the parameter root
?
a. swaps the left and right subtrees of the root node
b. swaps any two leaf nodes that have the same parent
c. swaps the leftmost and rightmost leaves
d. replaces the tree with its mirror image
e. none of the above
6. Consider the following methods:
If root
initially points to the root of the following tree:
what tree results from the execution of the following statements?
root.right = temp; }
}
return -
1
;
}
public static void preorder(Node root, Stack<Character> s) {
if (root != null) {
s.push(root.val);
preorder(root.left, s);
preorder(root.right, s);
}
}
public static void postorder(Node root, Stack<Character> s) {
if (root != null) {
postorder(root.left, s);
postorder(root.right, s);
root.val = s.pop();
}
}
A
/ \
B C
/ \ / \ D E F G
12/17/23, 8:15 PM
Final Exam Practice Problems — CS 112, Boston University
https://www.cs.bu.edu/courses/cs112/final_practice.html
4/14
a. b. c. d. e. 7. If a binary search tree is not allowed to have duplicates, there is more than one way to
delete a node in the tree when that node has two children. One way involves choosing a
replacement node from the left subtree. If this is done, which node are we looking for?
a. the largest node in the subtree
b. the smallest node in the subtree
c. the root of the left subtree
Stack<Character> s = new LLStack<Character>();
preorder(root, s);
postorder(root, s);
A
/ \
B C
/ \ / \ D E F G
A
/ \
C B
/ \ / \ G F E D
G
/ \
D F
/ \ / \ A B E C
A
/ \
C B
/ \ / \ F G D E
G
/ \
F D
/ \ / \ E C B A
12/17/23, 8:15 PM
Final Exam Practice Problems — CS 112, Boston University
https://www.cs.bu.edu/courses/cs112/final_practice.html
5/14
d. the next-to-smallest node in the subtree
e. it doesn’t matter – any node in the left subtree will do
8. The binary search tree shown below was constructed by inserting a sequence of items into
an empty tree.
Which of the following input sequences will not
produce this binary search tree?
a. 5, 3, 4, 9, 12, 7, 8, 6, 20
b. 5, 9, 3, 7, 6, 8, 4, 12, 20
c. 5, 9, 7, 8, 6, 12, 20, 3, 4
d. 5, 9, 7, 3, 8, 12, 6, 4, 20
e. 5, 9, 3, 6, 7, 8, 4, 12, 20
9. If the keys in the tree below are printed using a preorder traversal, what will the result be?
a. 9 4 17 16 12 11 6
b. 9 17 6 4 16 22 12
c. 6 9 17 4 16 22 12
d. 6 17 22 9 4 16 12
e. 6 17 9 4 22 16 12
6
/ \
17 22
/ \ / \ 9 4 16 12
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Web technology Question:
Professor don't reject this....I need this answer otherwise I will report to administration....please answer it according to asked question.
Q.No.2. Suppose there is a MySQL database named MyDatabase, the name of database server is DatabaseServer, User Name for the database server "Ghazi Messam" and Password is “1121”
There is one table named tbl_Projects (ProjectSID, ProjectTitle, ProjectSupervisor,CellNo,Email).
As project title is: Student Registration form
As project supervisor is: Ghazi Messam
As cell no: 03137025001
As Email is: ghazimessam@gmail.com
You are required to design a HTML page to get the value for each of these attributes. Then finally post the data to next page and store the input data to database.
Add Screen Shot of Creating database, Database Table and Sample Data.
arrow_forward
In the context of Android app development, explain the differences between data binding and view binding. When would you choose one over the other, and why?
arrow_forward
database system computer science
arrow_forward
Exercise
Wellmeadows Hospital
Patient Medication Form
• Illustrate the
Patient Number: P1O034
Full Name: Robert MacDonald
Ward Number: Ward 11
process of
normalizing the
data shown in
the form on your
Bed Number: 84
Ward Name: Orthopaedic
Drug
Number
Name Description Dosage Method of Units per Start Date Finish Date
Admin
Day
right side.
10223 Morphine
Pain Killer 10mg/ml
Oral
50
24/03/04| 24/04/05
10334 Tetracyclene Antibiotic | 0.5mg/ml
IV
10
24/03/04| 17104/04
10223 Morphine
Pain Killer 10mg/ml
Oral
25/04/05 | 02105/06
10
arrow_forward
PLEASE SHOW ALL WORK AND COMMENT ALL CODE
The Objective of this coding problem is the prediction of a proposed metro ectension construction project based on the people'es opinion. There are three alternatives to choose they are as follows:
Eglington-Pickering Line
Airport-Vaughn Line
Airposrt-Hamilton Line
Each record is represented by 16 features.
Task-1:
Metro-Ext.xlsx is the training and test dataset; you will considerr 80% of the data for training and 20% for the test. Build (1) Logistic regression (2) KNN and (3) Naive Bayes model to predict on the test data set and compute the confusion matrix for each model and compare the result.
deliverables = coding files (.py and .ipynb), and a discussions of confusion matrix for both models
metro-EXT.xlsx (Please place chart in EXCEL)
Feasibility and Constructability
Slopes and Gradients
Urban Realm
Geology and Soil Stability
Land Acquisition
Work Opportunities
Economy in Movement of People
Revenue Generation
Access to the Social,…
arrow_forward
Loan Star Credit Services Inc. (LSCS) receives from various parties requests to investigate the credit status of customers. Each credit request is identified by a Request_ID and is described by a Request_Date, Requesting_Party_Name, and Request_Period (whose value is derived by the request date and current date). LSCS also receives results of credit checks. Each credit check is identified by a Credit_Check_ID and is described by Credit_Check_Date and Credit_Check_Result. LSCS associates each credit request with a credit check. Each credit check result may be used in support of one to many credit requests. A credit request may be recorded before its credit check date. Draw an entity-relationship diagram (ERD) for this situation using the Crow's foot notation introduced in class. You may download and modify this template file (using Draw.io site Links to an external site.; click "File > Open from > Device ..." and navigate to the file you downloaded) for your drawing in this part,…
arrow_forward
What is a composite data type, and how is it used in programming? Provide examples of composite data types in different programming languages.
arrow_forward
25. Kelly wants to store some data in her program that concerns iPhone replacement chip shipments. She
needs to keep track of the inventory and has labeled each replacement part with a unique key. She is going to
have to enter in the new replacement parts periodically, but insertion will rarely be used. She will need to have
very fast look-up times to keep up with the ordering system. And deletions are never allowed. Which data
structure would be good for Kelly to use, what is her advantage and disadvantage by using this data structure?
arrow_forward
Describe the main components involved in the data binding process.
arrow_forward
When you say "metadata," what do you mean exactly? In the context of a data set, the following is a definition of metadata: When might it be helpful to use information pulled from a set of results?
arrow_forward
How do data dictionaries facilitate the process of data migration between different platforms?
arrow_forward
For the term project, you should write a report on a chosen topic related to your field. Follow the steps below:
Choose a topic : Technology
Narrow it down : Algorithms and data structures
Find at least 10 related articles to your topic
Read the articles, synthesize them and report the parts you want.
Use appropriate citations and quotations (APA 6th or 7th edition)
You need a reference list at the end of your report.
The report should be minimum 1000 and maximum 2000 words.
arrow_forward
Q_5
arrow_forward
a. The following pair of concepts are related in some way and different in another. Explain how the concepts are similar and how they are different: TABLE / VIEW
b. The following pair of concepts are related in some way and different in another. Explain how the concepts are similar and how they are different: UPDATE / ALTER
c. The following pair of concepts are related in some way and different in another. Explain how the concepts are similar and how they are different: DELETE / DROP
arrow_forward
Attracted by the success of Spotify, a group of students want to build their own music-streaming website called Musicmatic. Being economists, they are unaware of the specificities of databases and have therefore asked you to create an EER model.
A large number of songs will be made available through their website, and the following information on each song needs to be stored: title, year, length, and genre. Also, artist information will be added, including date of birth, name, and a URL to a website (e.g., Wikipedia page) with additional information on the artist. You can assume an artist is uniquely identified by her name, and that a song always belongs to exactly one artist. The Musicmatic students also point out that songs having the same title are possible, and only the combination of song and artist can be assumed to be unique.
The database will also have to store information on the people using Musicmatic. It was decided to only discriminate between two types of users: regular…
arrow_forward
Mention what is user-defined data type?
arrow_forward
Question 4 Ordinal data is a sub-part of the numerical data category within the data taxonomy.
True False
arrow_forward
sestion 12
Quiz
yet
avered
Match the terms in column A to the terms in column B: There is one extra phrase in column
B that do ot match with any term in Column A.
ed out of
Column A
Column B
SDLC
1)
extended period of time. This process is referred to as
When both the old and new systems operate for an
2)
Instantiation
2)
Creates and manages problem domain and,
processes business logic.
3)
Domain layer
3)
The process of creating a new object using the
template provided by the class definition.
4)
methodology for developing, deploying, and maintaining a
software system.
4)
Storyboarding
A term used to describe the process and
5) A technique that shows a sequence of sketches of the
display screen during a dialogue
5)
Parallel installation
6)
interactions with an application.
A term that relates to all aspects of a person's
Write your answer below by writing the corresponding sentence number from Column
arrow_forward
Exactly what is metadata? The term "metadata" refers to information about a result set. When is it appropriate to make use of the meta-data included inside a data set?
arrow_forward
You need to create a web application that will allow patients to book boththeir Covid-19 vaccine and flu shot appointments.Describe, in detail, at least two data structures that could be used in thisapplication.How would the data structures you identified help with the solution of thisproblem?Your answers should explore the topics in-depth and not be trivial.
arrow_forward
Create a Visual Studio Application / Solution Project based on a real life situation to computerize its existing manual system. Imagine that you are told to develop a software system to manage Employee details of a company.
a) Create a database called HOSPITAL and a table with a name PATIENT inside the database. The table should contain at least 8 columns of various data types.
b) Add at least 15 records into the table PATIENT.
c) Configure the database and display all the records from the table PATIENT on the Form with Details View as well as Data Grid View.
arrow_forward
Prestige data is data set in the package carData in R. Download and install this
package and use it to perform the following exercises.
1. (a) How can you show the structure of the data? What data structure is prestige and
what data type is each variable in Prestige?
(b) What are the dimensions of the data?
(c) Display the first six and last six rows of the data
arrow_forward
How is data binding utilized in Android app development, and what are the benefits it offers to developers?
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Fundamentals of Information Systems
Computer Science
ISBN:9781337097536
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781285196145
Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:Cengage Learning
Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781305971776
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning
Related Questions
- Web technology Question: Professor don't reject this....I need this answer otherwise I will report to administration....please answer it according to asked question. Q.No.2. Suppose there is a MySQL database named MyDatabase, the name of database server is DatabaseServer, User Name for the database server "Ghazi Messam" and Password is “1121” There is one table named tbl_Projects (ProjectSID, ProjectTitle, ProjectSupervisor,CellNo,Email). As project title is: Student Registration form As project supervisor is: Ghazi Messam As cell no: 03137025001 As Email is: ghazimessam@gmail.com You are required to design a HTML page to get the value for each of these attributes. Then finally post the data to next page and store the input data to database. Add Screen Shot of Creating database, Database Table and Sample Data.arrow_forwardIn the context of Android app development, explain the differences between data binding and view binding. When would you choose one over the other, and why?arrow_forwarddatabase system computer sciencearrow_forward
- Exercise Wellmeadows Hospital Patient Medication Form • Illustrate the Patient Number: P1O034 Full Name: Robert MacDonald Ward Number: Ward 11 process of normalizing the data shown in the form on your Bed Number: 84 Ward Name: Orthopaedic Drug Number Name Description Dosage Method of Units per Start Date Finish Date Admin Day right side. 10223 Morphine Pain Killer 10mg/ml Oral 50 24/03/04| 24/04/05 10334 Tetracyclene Antibiotic | 0.5mg/ml IV 10 24/03/04| 17104/04 10223 Morphine Pain Killer 10mg/ml Oral 25/04/05 | 02105/06 10arrow_forwardPLEASE SHOW ALL WORK AND COMMENT ALL CODE The Objective of this coding problem is the prediction of a proposed metro ectension construction project based on the people'es opinion. There are three alternatives to choose they are as follows: Eglington-Pickering Line Airport-Vaughn Line Airposrt-Hamilton Line Each record is represented by 16 features. Task-1: Metro-Ext.xlsx is the training and test dataset; you will considerr 80% of the data for training and 20% for the test. Build (1) Logistic regression (2) KNN and (3) Naive Bayes model to predict on the test data set and compute the confusion matrix for each model and compare the result. deliverables = coding files (.py and .ipynb), and a discussions of confusion matrix for both models metro-EXT.xlsx (Please place chart in EXCEL) Feasibility and Constructability Slopes and Gradients Urban Realm Geology and Soil Stability Land Acquisition Work Opportunities Economy in Movement of People Revenue Generation Access to the Social,…arrow_forwardLoan Star Credit Services Inc. (LSCS) receives from various parties requests to investigate the credit status of customers. Each credit request is identified by a Request_ID and is described by a Request_Date, Requesting_Party_Name, and Request_Period (whose value is derived by the request date and current date). LSCS also receives results of credit checks. Each credit check is identified by a Credit_Check_ID and is described by Credit_Check_Date and Credit_Check_Result. LSCS associates each credit request with a credit check. Each credit check result may be used in support of one to many credit requests. A credit request may be recorded before its credit check date. Draw an entity-relationship diagram (ERD) for this situation using the Crow's foot notation introduced in class. You may download and modify this template file (using Draw.io site Links to an external site.; click "File > Open from > Device ..." and navigate to the file you downloaded) for your drawing in this part,…arrow_forward
- What is a composite data type, and how is it used in programming? Provide examples of composite data types in different programming languages.arrow_forward25. Kelly wants to store some data in her program that concerns iPhone replacement chip shipments. She needs to keep track of the inventory and has labeled each replacement part with a unique key. She is going to have to enter in the new replacement parts periodically, but insertion will rarely be used. She will need to have very fast look-up times to keep up with the ordering system. And deletions are never allowed. Which data structure would be good for Kelly to use, what is her advantage and disadvantage by using this data structure?arrow_forwardDescribe the main components involved in the data binding process.arrow_forward
- When you say "metadata," what do you mean exactly? In the context of a data set, the following is a definition of metadata: When might it be helpful to use information pulled from a set of results?arrow_forwardHow do data dictionaries facilitate the process of data migration between different platforms?arrow_forwardFor the term project, you should write a report on a chosen topic related to your field. Follow the steps below: Choose a topic : Technology Narrow it down : Algorithms and data structures Find at least 10 related articles to your topic Read the articles, synthesize them and report the parts you want. Use appropriate citations and quotations (APA 6th or 7th edition) You need a reference list at the end of your report. The report should be minimum 1000 and maximum 2000 words.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Fundamentals of Information SystemsComputer ScienceISBN:9781337097536Author:Ralph Stair, George ReynoldsPublisher:Cengage LearningDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage Learning
- Principles of Information Systems (MindTap Course...Computer ScienceISBN:9781305971776Author:Ralph Stair, George ReynoldsPublisher:Cengage Learning
Fundamentals of Information Systems
Computer Science
ISBN:9781337097536
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781285196145
Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:Cengage Learning
Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781305971776
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning