Design an algorithm to find all the common elements

Assignment Help Basic Computer Science
Reference no: EM13935077

Analysis of Algorithms

1.     What is the smallest number of divisions made by Euclid's algorithm among all inputs 1 ≤ m, n ≤ 30?

2.     What is the largest number of divisions made by Euclid's algorithm among all inputs 1 ≤ m, n ≤ 30?

3.     #5, Exercises 1.1

Design an algorithm to find all the common elements in two sorted lists of numbers. For example, for the lists 2, 5, 5, 5 and 2, 2, 3, 5, 5, 7, the output should be 2, 5, 5.What is the maximum number of comparisons your algorithm makes if the lengths of the two given lists are m and n, respectively?

4.     #12, Exercises 1.1 

Locker doors - There are n lockers in a hallway, numbered sequentially from 1 to n. Initially, all the locker doors are closed. You make n passes by the lockers, each time starting with locker #1. On the ith pass, i = 1, 2, . . . , n, you toggle the door of every ith locker: if the door is closed, you open it; if it is open, you close it. After the last pass, which locker doors are open and which are closed? How many of them are open? 

5.     #1, Exercises 1.2

OldWorld puzzle Apeasant finds himself on a riverbank with a wolf, a goat, and a head of cabbage. He needs to transport all three to the other side of the river in his boat. However, the boat has room for only the peasant himself and one other item (either the wolf, the goat, or the cabbage). In his absence, the wolf would eat the goat, and the goat would eat the cabbage. Solve this problem for the peasant or prove it has no solution. (Note: The peasant is a vegetarian but does not like cabbage and hence can eat neither the goat nor the cabbage to help him solve the problem. And it goes without saying that the wolf is a protected species.)

6.     #2, Exercises 1.2

NewWorld puzzle There are four people who want to cross a rickety bridge; they all begin on the same side. You have 17 minutes to get them all across to the other side. It is night, and they have one flashlight. A maximum of two people can cross the bridge at one time. Any party that crosses, either one or two people, must have the flashlight with them. The flashlight must be walked back and forth; it cannot be thrown, for example. Person 1 takes 1 minute to cross the bridge, person 2 takes 2 minutes, person 3 takes 5 minutes, and person 4 takes 10 minutes. A pair must walk together at the rate of the slower person's pace. (Note: According to a rumor on the Internet, interviewers at a well-known software company located near Seattle have given this problem to interviewees.)

7.     #4, Exercises 1.3

K¨onigsberg bridges The K? onigsberg bridge puzzle is universally accepted as the problem that gave birth to graph theory. It was solved by the great Swiss-born mathematician Leonhard Euler (1707-1783). The problem asked whether one could, in a single stroll, cross all seven bridges of the city of K? onigsberg exactly once and return to a starting point. Following is a sketch of the river with its two islands and seven bridges:

a. State the problem as a graph problem.

b. Does this problem have a solution? If you believe it does, draw such a stroll; if you believe it does not, explain why and indicate the smallest number of new bridges that would be required to make such a stroll possible. 

8.     #4, Exercises 1.4

a. Let A be the adjacency matrix of an undirected graph. Explain what property

of the matrix indicates that

i. the graph is complete.

ii. the graph has a loop, i.e., an edge connecting a vertex to itself.

iii. the graph has an isolated vertex, i.e., a vertex with no edges incident to it.

9.     #8, Exercises 1.4 

How would you implement a dictionary of a reasonably small size n if you knew that all its elements are distinct (e.g., names of the 50 states of the United States)? Specify an implementation of each dictionary operation. 

10.            #8, Exercises 2.1 

For each of the following functions, indicate how much the function's value

a. log2 n   b. square root of n     c. n   d. n^2   e. n^3   f. 2^n

Reference no: EM13935077

Questions Cloud

Confront ethical issues in australian organisations : Explain how leaders can confront ethical issues in Australian organisations.
How have changes in information technology : How have changes in information technology impacted management of the value chain?
It has one button called exit, to quit the program. : Grades for the courses at the college are based on the sum of three assignments, and each assignment is worth a maximum of 100 points. The maximum points a student can get in a course is 300 points. To pass the course, a student needs 189 points o..
Create case manifest and record order fulfillment : Develop sequence diagrams for the use cases Enter New Order, Create Case Manifest and Record Order Fulfillment . Update the design class diagram with attribute information and method signatures derived from the sequence diagrams.
Design an algorithm to find all the common elements : Design an algorithm to find all the common elements in two sorted lists of numbers. For example, for the lists 2, 5, 5, 5 and 2, 2, 3, 5, 5, 7, the output should be 2, 5, 5.What is the maximum number of comparisons your algorithm makes if the lengths..
Impact made by culture on organizational politics : a) What are the individual and organizational factors that contribute towards the type of organizational political climate you are familiar with b) What is the impact made by culture on organizational politics?
Specify technical requirements based on inputs : Develop a design plan and schedule detailing your plans for the next 4 weeks in order to deliver the tasks specified. This should cover what design decisions must be made and who should make them; what tasks must be performed and in what order;
Create user interface similar to one pictured in this link : Use a second group of RadioButton controls to select whether a student handed in the assignment on time, with the default being
Why only eukaryotic cells found in multicellular organisms : Often, prokaryotic cells exist as simple unicellular organisms, but in some species, prokaryotic cells can grow together in colonies or filaments. In addition, some species, such as Cynaobacteria or Myxobacteria, demonstrate intercellular communic..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What are difference between oop and object orinted design

What is the difference between object oriented programming and object oriented design

  Create a class includes instance variables

Create a class called Employee that includes three pieces of information as either instance variables or automatic properties - a firstname (type string), a last name (type string) and a monthly salary (decimal) Your class should have a constructo..

  Write a program that asks for the amount of the bill

Write a program that asks for the amount of the bill and percentage tip and calculates the tip. The program should use variables for each of the quantities and display the outcome in a text box with a label. Test the program on a bill of $20 and a..

  The financial director of a private school would like

The financial director of a private school would like a tracking system for the students at the school

  Wish to represent an n-vertex graph

Suppose we wish to represent an n-vertex graph G using the edge list structure, assuming we identify the vertices with the integers in the set {0,1,...,n?1}.

  Ipo chart its components and benefits to program development

Discuss the IPO chart, its components, and its benefits to program development. In your opinion, what would be the impact if one of these components were omitted? Thoroughly explain.

  How spki be augmented to support policy

Consider a policy that, for reasons of separation of duties, does not allow an entity to exercise the rights it may grant (delegate) to others. How could SPKI be augmented to support such a policy?

  What is the addressing mode of the instruction

What is the addressing mode of the instruction

  Several policies or events that affect the performance

Several policies or events that affect the performance of the economy

  Consider a processor that runs at 2.5 ghz

Consider a processor that runs at 2.5 GHz and 1 Volt. When running a given CPU-bound program, the processor consumes 100 W, of which 20 W is leakage. The program takes 10 seconds to execute. The processor is capable of running at different voltages a..

  Java game development jump it

The game "Jump It" consists of a board with n positive integers in a row, except for the first column, which always contains zero. These numbers represent the cost to enter each column. Here is a sample game board with n set to 6:

  Truth table validity of demorgan-s theorem for variables

Find out by means of truth table validity of DeMorgan's theorem for three variables: (ABC)' = A' + B' + C'. Simplify given expressions by using Boolean algebra.

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