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

  Use the first set of information to create an online order

After the orders are placed, print a report of the inventory reflecting the current items in the inventory. You will also need to create the inventory object with at least 3 items instock.

  Splits the word into a unicode character array

These tasks entail developing a single program that contains methods of the following tasks. Your program may run either on the command-line or as an applet. Write methods that take a word input by the user (10%) and then: (10%) splits the word int..

  How do you write a program that prompts a professor

ow do you write a program that prompts a professor to imput grades for five different courses for ten students

  What type information is carried by data bus and address bus

What type of information is carried by the Data Bus? The Address Bus?

  Describe wal-mart''s stance corporate social responsibility

Describe the Wal-Mart's stance on corporate social responsibility (CSR). 2. Discuss the connection between the CSR program and why it is necessary to the specific industry

  Information literacy is defined as a set of skills

Which of the following documents are considered primary sources. Information literacy is defined as a set of skills needed to

  Application uses both warehouse and operational data

Field sales people can have a sales database on their smart phones. The sales database contains sensitive, competitive information. Using their smart phones, the salespeople can query the data, update it, delete it, and place orders. This application..

  Explain applications of pervasive computing

Which of the applications of pervasive computing do you believe are probable to gain greatest market acceptance over next few years? Why?

  Database design vince''s viny

Based on your selected scenario from Hands-On Database, complete the "To Do" activities described at the end of Chapter 4 of the textbook. Your response should be submitted as a Word document.

  What is the function of secondary storage

What is the function of secondary storage? Describe three types of secondary storage media, and describe the advantages and disadvantages of each type.

  What is the difference between the result of statements

What is the difference between the result of the following two statements. int cents = (int)(100 * price + 0.5)

  Define boot sector and file

Define each of the following terms in your own words: Boot sector, File, Multipartite and Macro

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