S23-solutions (3)
.pdf
keyboard_arrow_up
School
Rutgers University *
*We aren’t endorsed by this school
Course
112
Subject
Computer Science
Date
Apr 26, 2024
Type
Pages
9
Uploaded by AgentCaribouMaster1086
CS112 Data Structures - Final - Spring 2023 Name: _____________________________________ NetID: __________________________ 1 •
WRITE your name
and NetID
on EVERY page. •
DO NOT REMOVE
the staple on your exam.
•
WRITE NEATLY AND CLEARLY. If we cannot read your handwriting, you will not receive credit. Please plan your space usage. No additional paper will be given. •
This exam is worth 150 points. •
This exam has 10 pages, make sure you have all the pages. Problem 1 – Miscellaneous (25 points) a)
(10 points)
Answer TRUE or FALSE for each of the following statements. 1. The worst-case running time to search in a singularly linked list with n
items is O(1) time. False 2. Deleting the first node in a circular linked list with n
items takes O(1) time. True 3. Deleting the first node in a singularly linked list with n
items takes O(n) time. False 4. Insertion into a balanced BST with n
items takes O(log n) time. True 5. The worst-case running time to search for a value in a 2D n x n
array takes O(n) time. False 6. Stacks can be used to represent the line of students waiting for office hours where students are seen in a First-In-First-Out manner. False 7. A BST guarantees O(log n) for searches on a tree with n
items. False 8. Stacks can be used to reverse a list of objects. True 9. The maximum height of a 2-3 tree with n
items is log
2
n. True 10. Union find can be used to determine if two items are connected. True [1 point] each correct b)
(5 points) Assume a linked list of n
integers, where n > 0
. What does the mystery
method print? What is
the running time of the method mystery
in big O notation? [4 points] Prints out the minimum value in the linked list. [1 point] O(n)
CS112 Data Structures - Final - Spring 2023 Name: _____________________________________ NetID: __________________________ 2 c)
(10 points) Assume a sorted array of n
items with duplicates, where n > 0
. Each item could appear at most k times. When searching for an item, the search algorithm is modified to display the first and last indices of the item in the array. If the item is not found the algorithm displays -1 and -1. For example, the search for 36 displays 5 (first index) and 10 (last index). An item appears at most k
times.
Briefly describe the fastest search algorithm to display the first and the last indices of a sequence of non-
distinct items. Your algorithm may not
modify the array or use extra memory. What is the algorithm’s running time in terms of n
and k
? Explain. [0 points] for any algorithm that is takes longer than log n + k Algo [4 points] Use binary search to find the item. [1 point] Scans left until it finds a distinct item, display start index. [1 point] Scans right until it finds a distinct item, display end index. Running time [1 point] binary search takes log n. [1 point] scanning left and right takes at most k checks. [2 point] running time is log n + k
CS112 Data Structures - Final - Spring 2023 Name: _____________________________________ NetID: __________________________ 3 Problem 2 – Priority Queue (25 points)
a)
(7 points) Suppose that you are asked to devise the fastest algorithm to find the second largest integer value in a MAX heap of n
integers with duplicates. Assume that: •
there are at least two distinct values. •
you have direct access to the array that holds the heap items. •
you cannot modify the heap. (i)
(2 points)
Where could the second largest item be in the heap? The second largest value could be anywhere in the heap except at the top (first element) (ii)
(3 points)
Describe the algorithm. Compare every item against the top/max of the heap. (iii)
(2 points) What is the worst-case big O running time? Give a one sentence description in addition to big O. [1 point] O(n) [1 point] In the worst case we will need to compare every item against the top of the heap, and the last item we compare is the second largest. b)
(8 points) Briefly explain how to use a priority queue to implement a stack. •
What kind of priority queue is needed? •
How are the push and pop operations implemented? [2 point] MAX PQ [2 point] Associate each stack item with a key (number or timestamp). Start the key at a value. The last item inserted into the PQ have the largest value and therefore will be the first to be removed.
[2 point] Push: insert item into the PQ and then increment the key. [2 point] Pop: remove the largest value from the PQ c)
(10 points) Implement the fastest algorithm to find the minimum key in a MAX PQ. Hint: the minimum key is one of the leaves. // No points if algorithm takes longer than O(n) // The algo is supposed to investigate the leaves ONLY: indices n/2+1 to n
CS112 Data Structures - Final - Spring 2023 Name: _____________________________________ NetID: __________________________ 4
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
Html code for sure in this design java
.
arrow_forward
Canvas
• Add a Level Two Section Heading with "Canvas" as its content under the HTML for Part 2
• Add a Canvas element to index.html
Find an example online (or from the textbook) that uses JavaScript to draw on a Canvas
element
o Choose one example and implement it in index.html
arrow_forward
Create a webpage A2-Task2.html.
The webpage is displaying one image. Each time the user moves the mouse out of the image, the image is
changed to another one and one more 'sun' emoji is displayed under the image. When the number of 'suns'
reaches seven (7), all 'suns are deleted (reset) and start to be displayed again. For example, the 8th time user
moves the mouse out of the image, one 'sun' is shown, the 9th time - two 'suns', and so on.
Note:
- You should use two images. Each time the user moves the mouse out of the image, the image is changing. If
an image of "Winter" is displayed it will change to "Summer", and opposite, if an image of "Summer" is
displayed it will change to "Winter".
The special character code for the 'sun' is "☀".
Put the source code of your website A2-Task2.html here.
Make sure you also upload the A2-Task2.zip of all files below.
arrow_forward
Objective:To add scripting to the existing web page and work with JavaScript Es-6 features like class, object , getter methods and collection.
Problem Description:As part of a simple billing application, you are provided with an html page to obtain inputs for item number, item name, price & quantity. Using the ES-6 collections, add every item object into a Set and iterate through it to find the total cost to be paid. On adding each item object into Set, it must also get added to the table as a new record. Refer to the screenshot.
Following are the files that contain code snippets
index.html
HTML for webpage (complete implementation is given for you). You only have to run this. No change needs to be done in this file.
script.js
Add your code to this file for the functions given.
Procedure to complete the exercise
Class
Properties
Methods
Item
itemNumberitemNamepricequantity
Include constructor with properties and getter methods for Item properties…
arrow_forward
Question 9
Program a CSS ruleset that will set the root font size for the HTML document to match the user's browser
preference.
Feedback
Question 2
Program a CSS media query that is triggered if the screen is at least 900px wide, but use em as the size unit in
the query.
Within the media query, write a rule for an element with a id equal to header. That rule should set the font
size to three times the current size.
Note: You should assume the parent element's font-size is equivalent to 16px.
@media screen and (min-width: 56.25em) {
.header {
font-size:300%;
}
}
arrow_forward
please answer all thanks !!!
arrow_forward
Using PHP and PHP arrays, Please create a script that makes a complete online shopping cart, where the user can add, remove, and change the quantity of items in the shopping cart. (the shopping cart must have 10 items with corresponding descriptions (Note: you do not have to actually write in products and descriptions, use PLACEHOLDER for these.) The shopping cart should include a checkout process that includes the total price of the items they are purchasing. (Note: HTML may also be used if required)
arrow_forward
Write the HTML, CSS, and JS to implement a very primitive spreadsheet program that meets the following requirements:
The page shall appear similar to this:
A
B
Rent
400
Food
200
Entertainment
100
Transportation
50
Total
750
The values in column B (except for the Total) shall be editable by the user.
Whenever the user changes a value in column B, the Total shall be automatically recalculated.
arrow_forward
web
arrow_forward
computer graphics simple utilty curvewrite c#.net and send the designi need same link design and code and output
please curve and i need to input the Coordinates
https://www.codeproject.com/Articles/5267642/A-Simple-Utility-for-Drawing-Function-Curves
arrow_forward
I'm creating a webpage that creates an appropriate greeting using the current date and time. See the instructions.
arrow_forward
Link List with GraphicsFor this project you will be creating a link list and drawing the nodes to the screen. Each node will be drawn as a rectangle. Each node will have the ability to link to at least 4 other nodes. Create a SDL2 project to open a graphics window for this assignment. Set the background color to something dull. Create a Node structure as follows to create the nodes for the link list. Node:• rectangle SDL_Rect• color SDL_Color or rgb values, your choice• 4 Node pointers (links)• draw() Draws a solid (filled) rectangle• Node() Add arguments to your constructor(s) as you see fitBefore your main loop create 5 Node objects on the heap. Link the nodes to each other in the pattern shown below. Begin by linking each node to the node adjacent to it. The center node will be linked to all 4 surrounding nodes. Then link each outer node to the node on the opposite side, creating a wraparound effect as indicated by the green arrows. Create a Node pointer called current and set it…
arrow_forward
I have to call meta fields from current post id in HTML
<div title="Add to Calendar" class="addeventatc">Add to Calendar<span class="start">03/25/2022 08:00 AM</span><span class="end">03/25/2022 10:00 AM</span><span class="timezone">America/Los_Angeles</span><span class="title">Summary of the event</span><span class="description">Description of the event</span><span class="location">Location of the event</span></div>
To add event to calendar for webinar panels
arrow_forward
Lect 1A: linked-list
HW 1 link list : Create Visual C++ project and.
Due Tomorrow, 4:00 AM
Posted 3:19 PM
Project name should be 'HW1+student name for example 'HW1 Ahmed Ali Ahmed'
18
-Compress the project file as zip file and upload it here.
-Screenshots for the entire codes and classes
Turned in
Assigned
-Screenshot for the result.
View assignment
تسجبل محاطرة يوم 5/5/2021
Posted 3:14 PM
...
arrow_forward
Create a 10-point quiz (radio button) using a
multidimensional array with the use of HTML elements (forms and tables).
Provide an array of answer key and it must check the selected answers of the user.
arrow_forward
html, css, and javascript are languages that can be used together
arrow_forward
Please help me with the following exercise.
Use your programming environment to generate a simple Web site using Python flask. The site should be unique, include at least 3 routes (e.g. 3 pages one can navigate), each route should render the HTML pages by using the render_template() functionality.
A style sheet should be included that is used by all Web pages.
Proper organization should take place of the web site including the location of templates and static pages.
Keep in the basic HTML form for a function web page includes the following components:
<!DOCTYPE html><html><head><title>Page Title</title></head><body>...your page content...</body></html>
In addition to the requirements list above the following functionality should be found within your web site on one or more web pages.• Use at least 3 different heading styles (e.g. <h1>, <h2>, <h3>)• Paragraph (<p>)• Comments <!-- -->)• Ordered list•…
arrow_forward
1. What are the frameworks available for the frontend and backend of website development?
2. What function does this Syntax perform?
function myMap() {var map Canvas = document.getElementById("map");var mapOptions = {center: new google.maps.LatLng(51.5, -0.2),zoom: 10};var map = new google.maps.Map(mapCanvas, mapOptions);}
arrow_forward
Lab Exercise 1
Design a web page to and display the text “Welcome to Oman" using java script.
Try the different methods of including javascript into a web page.
Lab Exercise 2
Find the HTML element (with id="demo"), and changes the element content (innerHTML) to the
current date and time value:
Lab Exercise 3
Find the HTML element (with id="demo"), and changes the element content (innerHTML) to "Hello
JavaScript":
Lab Exercise 4
Design one HTML page with that will print the sum and product of two integer numbers with the help
of javascript variables.
Lab Exercise 5
Program to demonstrate the use of javascript Alert box.
Lab Exercise 6
Program to demonstrate the use of javascript Confirm box.
Lab Exercise 7
Program to demonstrate the use of javascript Prompt box.
arrow_forward
Describe how to construct and utilise an array in.NET.
arrow_forward
Create a NetBeans project for this activity. Project Name: MP1_<lastname_firstname> Example: MP1_Blanco_Maria
Compress the NetBeans project into .rar or .zip format and then upload to the link provided in the LMS.
Program Specification:
Use two-dimensional array with size 7 columns and 5 rows.
Seat numbers are populated during run-time and not hard-coded.
User is asked to input a seat number.
The chosen seat number is replaced by the letter X.
Program displays a remark “Seat successfully reserved” when reservation is done.
The class name should be SeatReservation_<lastname>.
Assessments
Example: SeatReservation_Blanco
Week005 – Machine Problem 1
Only NetBeans project will be accepted. Non-compliance will require resubmission. The highest score for resubmission is 50%.
The user is not allowed to reserve a previously reserved seat. Display “Seat is taken” remarks.
The user is not allowed to enter an invalid seat number.…
arrow_forward
computer graphics simple utilty curvei need to write c#.net and send the designi need same link design and code and output
https://www.codeproject.com/Articles/5267642/A-Simple-Utility-for-Drawing-Function-Curves
arrow_forward
Make a functional TODO LIST using HTML and customize it using CSS and make it interactive using JAVASCRIPT. You can copy the attached photo design or make your own design. (This is not graded question)
arrow_forward
mobile application development
android studio
q. Write a line (or multiple lines) of Java to make
a View rotate by 180 degrees clockwise over
200mS.
arrow_forward
Create a numbered list with numbering pattern “i, ii, iii……..” that starts from ‘v’ and not ‘i’ in html
arrow_forward
Please help with the question on Python Programming
arrow_forward
PLEASE REFER TO THE IMAGES FOR INSTRUCTIONS
PLEASE USE STARTER CODE - CODE IN PYTHON3
### starter code
import random
def spider_web(web_map, starting_place, destination):
pass
def spider_web_rec(web_map, starting_place, destination, visited):
pass
def make_spider_web(num_nodes, seed=0):
if seed:
random.seed(seed)
web_map = {}
for i in range(1, num_nodes + 1):
web_map[f'Node {i}'] = []
for i in range(1, num_nodes + 1):
sample = random.sample(list(range(i, num_nodes + 1)), random.randint(1, num_nodes - i + 1))
print('sample', i, sample)
for x in sample:
if i != x:
web_map[f'Node {i}'].append(f'Node {x}')
web_map[f'Node {x}'].append(f'Node {i}')
return web_map
if __name__ == '__main__':
num_nodes, seed = [int(x) for x in input('Input num_nodes, seed: ').split(',')]
the_web = make_spider_web(num_nodes, seed)
print(spider_web(the_web, 'Node 1',…
arrow_forward
Assignment
Create a well-formed valid XML file that contains this
information. The information does not have to be
correct only your name needs to be correct, you can
make up all other information. Then, create the proper
XSLT file to load that XML data and display it. When
displaying it, make sure you're using:
• Different font colors
• Tables
• header tags ( ...)
• Images where the image name is read from the
XML file
The information you must include:
• Name
• My Picture (this is an image file name. For
example: loay.jpg, or myphoto.jpg
• Address
o Street number
o City
o State
o Zipcode
• Movies I like
o Title
o Release Date
arrow_forward
Write a PHP script to do the following:
Create the following two dimensional array $students:
ID
Name
Score
100
Ali
76
200
Khaleed
33
300
Fatema
89
400
Sumaya
45
Use foreach to display the array $students in an HTML table.
Display the number of pass and fail students (pass if the score is greater than 50 and fail otherwise).
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Html code for sure in this design java .arrow_forwardCanvas • Add a Level Two Section Heading with "Canvas" as its content under the HTML for Part 2 • Add a Canvas element to index.html Find an example online (or from the textbook) that uses JavaScript to draw on a Canvas element o Choose one example and implement it in index.htmlarrow_forwardCreate a webpage A2-Task2.html. The webpage is displaying one image. Each time the user moves the mouse out of the image, the image is changed to another one and one more 'sun' emoji is displayed under the image. When the number of 'suns' reaches seven (7), all 'suns are deleted (reset) and start to be displayed again. For example, the 8th time user moves the mouse out of the image, one 'sun' is shown, the 9th time - two 'suns', and so on. Note: - You should use two images. Each time the user moves the mouse out of the image, the image is changing. If an image of "Winter" is displayed it will change to "Summer", and opposite, if an image of "Summer" is displayed it will change to "Winter". The special character code for the 'sun' is "☀". Put the source code of your website A2-Task2.html here. Make sure you also upload the A2-Task2.zip of all files below.arrow_forward
- Objective:To add scripting to the existing web page and work with JavaScript Es-6 features like class, object , getter methods and collection. Problem Description:As part of a simple billing application, you are provided with an html page to obtain inputs for item number, item name, price & quantity. Using the ES-6 collections, add every item object into a Set and iterate through it to find the total cost to be paid. On adding each item object into Set, it must also get added to the table as a new record. Refer to the screenshot. Following are the files that contain code snippets index.html HTML for webpage (complete implementation is given for you). You only have to run this. No change needs to be done in this file. script.js Add your code to this file for the functions given. Procedure to complete the exercise Class Properties Methods Item itemNumberitemNamepricequantity Include constructor with properties and getter methods for Item properties…arrow_forwardQuestion 9 Program a CSS ruleset that will set the root font size for the HTML document to match the user's browser preference. Feedback Question 2 Program a CSS media query that is triggered if the screen is at least 900px wide, but use em as the size unit in the query. Within the media query, write a rule for an element with a id equal to header. That rule should set the font size to three times the current size. Note: You should assume the parent element's font-size is equivalent to 16px. @media screen and (min-width: 56.25em) { .header { font-size:300%; } }arrow_forwardplease answer all thanks !!!arrow_forward
- Using PHP and PHP arrays, Please create a script that makes a complete online shopping cart, where the user can add, remove, and change the quantity of items in the shopping cart. (the shopping cart must have 10 items with corresponding descriptions (Note: you do not have to actually write in products and descriptions, use PLACEHOLDER for these.) The shopping cart should include a checkout process that includes the total price of the items they are purchasing. (Note: HTML may also be used if required)arrow_forwardWrite the HTML, CSS, and JS to implement a very primitive spreadsheet program that meets the following requirements: The page shall appear similar to this: A B Rent 400 Food 200 Entertainment 100 Transportation 50 Total 750 The values in column B (except for the Total) shall be editable by the user. Whenever the user changes a value in column B, the Total shall be automatically recalculated.arrow_forwardwebarrow_forward
- computer graphics simple utilty curvewrite c#.net and send the designi need same link design and code and output please curve and i need to input the Coordinates https://www.codeproject.com/Articles/5267642/A-Simple-Utility-for-Drawing-Function-Curvesarrow_forwardI'm creating a webpage that creates an appropriate greeting using the current date and time. See the instructions.arrow_forwardLink List with GraphicsFor this project you will be creating a link list and drawing the nodes to the screen. Each node will be drawn as a rectangle. Each node will have the ability to link to at least 4 other nodes. Create a SDL2 project to open a graphics window for this assignment. Set the background color to something dull. Create a Node structure as follows to create the nodes for the link list. Node:• rectangle SDL_Rect• color SDL_Color or rgb values, your choice• 4 Node pointers (links)• draw() Draws a solid (filled) rectangle• Node() Add arguments to your constructor(s) as you see fitBefore your main loop create 5 Node objects on the heap. Link the nodes to each other in the pattern shown below. Begin by linking each node to the node adjacent to it. The center node will be linked to all 4 surrounding nodes. Then link each outer node to the node on the opposite side, creating a wraparound effect as indicated by the green arrows. Create a Node pointer called current and set it…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education