Create a graph showing best average and worst case

Assignment Help Data Structure & Algorithms
Reference no: EM131210493

CS 361, Introduction to Data Structures Final Exam Fall 2015

You are not to communicate with anyone else in any manner concerning this exam during the exam period. The ODU Honor code is in effect for the duration. You are to solve no more than 3 of the following problems in C++, using the STL library; each code should run stand-alone as a simulation.  You can develop the code in any environment but they should compile using Code blocks. Submit your solutions as a single zipped file via blackboard.

Q1. Imagine that there are processes that are being generated at random intervals, each process has an id (0001 to 9999) and in addition each process has a complexity score that is directly proportional to the product of its required memory and its expected run time. We can treat the complexity score (c >= 0)  as a random value with a mean of 5and a standard deviation of 1. As the processes are generated they are placed into a queue of length q (q is user input).  Processes are removed from the front of the queue after they have been in the front for c time steps. IF a process is generated and the queue if full then the overload is placed in a separate priority queue with the lowest c score given the highest priority. When room is made in the process queue, it is refilled from the priority queue. Generate a simulation of this process handler.

Time

Queue

New Processes P-id(c)

Priority Queue

1

<> 

P1(3) P2(1)

<> 

2

<P1, P2>

P3(4)

<> 

3

<P1,P2,P3>

None

<> 

4

<P2,P3>

P5(1)

 

etc

22

<P44(2), P45, ...P54>

P55(3), P56(1)

<> 

23

<P44(2), P45,...P54>

P57(2)

<P56, P55>

24

<P44(2) P45, P54>

None

<P56, P57, P55>

Etc

<P45, P54, ...P54, P56>

None

<P57, P55>

Q2. Imagine a 3-d chess board (8x8x8) with one knight on it. The knight is placed at location level 0, row 0 and column 1, (standard position), implement an algorithm that will allow the knight to move around the board randomly until 90% of possible locations have been visited. Knights usually move a total of three spaces in an "L" shape. This is still true, but they now can go up one (or down) over two and up two (or down) and over one. There are 512 locations in a 3-d chess board.

Q3. This is an experimental question, please implement the following code fragment in a fully functional C++ code. Given ints j, n, and T: where n is user input, the functions b is return type bool, and both p and q each return a time cost. You will use the value T to store the cumulative sum of those costs.

i. For(j=0; j<n; j++)

ii. {If b(j) {T=T+q(j);}

iii Else {

1. If(b(j+1){T=T+q(j-1);}

2. Else {T=T+p(j+3);}

3. }

iv. }

Where  b(i) takes i+3 seconds and (on average) the function b( ) returns true 50% of the time q(i) takes i+1 seconds and p(i) takes i+2 seconds

Create a graph showing best, average, and worst case T scores for your code in number 3 above for n = powers of 2 from 21 to 216. If there are any results you cannot provide be specific as to the reason. You can modify the best/worst by modifying how often b( ) returns true.

Q4. Using your mountain project source code as a starting point, you are to write a code that randomly chooses one of the triangles on the surface of your mountain, this will be the entrance to your cave. A line segment representing that tunnel beginning at the centroid of that surface travels a distance equal to the average of the three sides of that triangle in the direction normal to that surface INTO the mountain. You should store this segment as a vector beginning at the centroid in the form  v = xmi + ymj + zmk . These xm, ym, and zm values will be referenced many times. At this point what happens is determined by the following table.

Probability

Event

0.10

Continue straight for the same distance as before

0.70

Tunnel changes direction by generating a new random vector direction such that when

 v=ai  + bj + ck

-xm< a <xm

-ym< b <ym

-zm< c <zm

.10

The tunnel splits in two by generating two different vectors  in the same way as the change of direction table above

.10

Current tunnel  branch terminates

As the tunnel splits then there is an additional branch that must be explored. If at any time a branch of the tunnel intersects the surface of your mountain that branch should terminate (hint: consider the 2-d projection of your quads as seen from above).

Save your tunnel system as a set of line segments in a separate data file then plot them with your mountain. They should automatically appear as a different color.

5. Create a class gene that contains a sequence of 4 amino acids (represented by chars A, T, C, G) Generate agene linked list of length L (user input) of class, this is a protein. Generate a second linked list of length L/2< L2 < L. Search for a matching sequence of at least 4 genes (16 acids) that can be found in both proteins. If none exist state so. If they do exist display at what index they can be found in each protein.

6. The equation of an ellipse is show below:

2365_Figure.png

If a and b are random integers in the range [1, 10] accept an integer N (2 to 5) from the keyboard, create N random ellipses, create a data file that contains x, y data for them and then plot them using gnuplot. This is a 2-d problem.

Reference no: EM131210493

Questions Cloud

Is strong us dollar always good for us and global economies : How do changes in interest rates, inflation, productivity, and income affect exchange rates? Is a strong U.S. dollar always good for the U.S. and global economies? Why or why not?
Internet for the history of that branding : In your first paragraph, briefly describe the branding item chosen and summarize its history from the article. Do not quote from the article or copy lists; write in your own words. End the first paragraph with a proper APA in-text citation.
Four levels of evaluation : Explain in your own words the four levels of evaluation: Reaction, Learning, Behavior and Results.
Analyze whether the regulation of pornography is warranted : Analyze the selected journal articles and identify any correlation between rape and pornography. Provide statistical information in support. Synthesize your research and conclude, with reasons, whether pornography leads to sexual violence. If not..
Create a graph showing best average and worst case : Create a graph showing best, average, and worst case T scores for your code in number 3 above for n = powers of 2 from 21 to 216. If there are any results you cannot provide be specific as to the reason. You can modify the best/worst by modifying ..
Common intermediate targets to guide policy in recent years : What are some common intermediate targets that the Fed has used to guide policy in recent years? - Give two criteria for intermediate targets.
Target the money supply and the demand for money falls : Assume that the Fed is targeting the money supply and the demand for money falls. - Explain why interest rates will fall.
Characteristics of gbr during the long boom : 1) What were some of the characteristics of GBR during the Long Boom? 2) What have been some of the characteristics of GBR during the neo-liberal era?
Target an interest rate and the demand for money increases : Assume that the Fed is targeting an interest rate and the demand for money increases. - Explain why the money supply will increase.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Analyze the algorithm and print the result

Suppose a maximum flow for G has been computed, but an edge is now removed form E. Describe how the maximum flow can be efficiently updated. Analyze your algorithm.

  Create a b-tree of order seven that has hundred entries

Using the B-tree ADT, create a B-tree of order 7 that has 100 entries. Use a random-number generator to randomly create the keys between 1 and 1000.

  Write an algorithm that traverses a tree

Write an algorithm that traverses a tree and prints all of its words in lexical order.

  Design a program that asks user to enter a series of numbers

Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and then display the following data.

  Prepare a flowchart to solve any linear equation

Prepare a flowchart to solve any linear equation ax^2+bx+C=0

  Write down a program which explores the seating patterns

write a program that explores the seating patterns related to course performance by using an array of student scores.

  Definitions and discussion on best-average-worst case

Definitions and discussion (0-complexity of algorithms discussed: best-average-worst case, doubly linked list, trees, binary trees, binary search trees, AVL, and b-tree.

  Advantages and five disadvantages of doubly linked lists

Write down atleast any five advantages and five disadvantages of doubly linked lists over singly linked lists in tabulated format

  Write down an all-pairs algorithm that is given a list of

question 1.algorithms a and b perform the same task. on input of size n algorithm a executes 0.5n2 steps and algorithm

  Quicksort will result in quadratic behavior

Describe a case where quicksort will result in quadratic behavior.

  Write program that initialize array with ten random integers

Write a program that initializes an array with ten random integers and then prints four lines of output, containing every element at an even index, every even element, all elements in reverse order and only the first and last element.

  Discuss fault tolerance approaches that systems managers use

Discuss fault tolerance approaches that systems managers use to assure continuity of operations

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd