0% found this document useful (0 votes)
39 views3 pages

Name: - : CS 3240 Spring 2011 Sample Final Exam

This document contains a sample final exam for a CS 3240 course. It includes 5 problems: 1) Determining the time complexity of two algorithms in Big-O notation. 2) Writing code to store airline ticket price data in a graph. 3) Writing a function to find the intersection of two unsorted lists. 4) Determining the time complexity of two sorting algorithms. 5) Implementing a recursive method to calculate the average value of nodes in a binary search tree.

Uploaded by

Doran Cu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views3 pages

Name: - : CS 3240 Spring 2011 Sample Final Exam

This document contains a sample final exam for a CS 3240 course. It includes 5 problems: 1) Determining the time complexity of two algorithms in Big-O notation. 2) Writing code to store airline ticket price data in a graph. 3) Writing a function to find the intersection of two unsorted lists. 4) Determining the time complexity of two sorting algorithms. 5) Implementing a recursive method to calculate the average value of nodes in a binary search tree.

Uploaded by

Doran Cu
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name:________________ CS 3240 Spring 2011 Sample Final Exam

Closed book and notes, 110 minutes Turn off your cell phones, pagers You may ask about any of the problems, but you may not ask about your answer

1. For each of the following problems, what is the time complexity (remember to use Big-O notation)? Briefly explain each answer, including what your n represents if appropriate (1-2 sentences) (a) Computing the average annual salary of a CSU-East Bay graduate.

(b) Determining the winner of an election where whoever has the most votes wins.

2.

Write code using the GraphType class to store the following information about airline ticket prices between various airports. DFW to SFO = $470 ORD to SFO = $150 ORD to DFW = $352 RDU to DFW = $372 SFO to ORD = $372

3.

Assume that the following functions are implemented:

ItemType minimum(UnsortedType *lst); ItemType maximum(UnsortedType *lst);

or, for Java:


public static ItemType minimum(UnsortedType lst); public static ItemType maximum(UnsortedType lst);

These functions return the smallest and largest values in the list parameter. Write a function intersection that takes two UnsortedType parameters and returns a pointer (C++) or reference (Java) to a new UnsortedType that contains the intersection of the parameter lists. The function should use the minimum() and maximum() functions to get the smallest and largest elements of the 2 nd parameter and avoid scanning the 2 nd list for values less than the minimum or greater than the maximum. The function is not a method in the UnsortedType class.

4.
a.

Give the time complexity (in Big-O) of the following algorithms. Briefly explain.

Given an array-based sorted list, create a copy in reverse order by: pushing the values of the sorted list on a stack, then popping the values off and adding them to the copy.

b. Given two unsorted linked lists, determine if they both contain the same values, but not necessarily in the same order (or the same number of times, so the lists {2, 1, 2} and {1, 2} would satisfy this constraint) for each item X in the first list search if X is in the other list, returning false if not found return true if all items in the first list are found in the second list.

For the TreeType class (BinarySearchTree for Java), assume that the info field of the node (TreeNode for C++, BSTNode for Java) is a float. Implement average, a method in TreeType that returns the average value of all values in the tree. The solution must be recursive to receive any credit, though you may choose to divide the solution into two functions, one recursive and one not.
5.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy