1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Musya8 [376]
3 years ago
14

You are a visitor at a political convention with delegates; each delegate is a member of exactly one political party. It is impo

ssible to tell which political party any delegate belongs to; in particular, you will be summarily ejected from the convention if you ask. However, you can determine whether any pair of delegates belong to the same party or not simply by introducing them to each other. Members of the same party always greet each other with smiles and friendly handshakes; members of different parties always greet each other with angry stares and insults.
Required:
Suppose more than half of the delegates belong to the same political party. Design a divide and conquer algorithm that identifies all member of this majority party and analyze the running time of your algorithm.
Computers and Technology
1 answer:
Fed [463]3 years ago
5 0

Answer:

The algorithm is as follows:

Step 1: Start

Step 2: Parties = [All delegates in the party]

Step 3: Lent = Count(Parties)

Step 4: Individual = 0

Step 5: Index = 1

Step 6: For I in Lent:

Step 6.1: If Parties[Individual] == Parties[I]:

Step 6.1.1: Index = Index + 1

Step 6.2: Else:

Step 6.2.1 If Index == 0:

Step 6.2.2: Individual = I

Step 6.2.3: Index = 1

Step 7: Else

Step 7.1: Index = Index - 1

Step 8: Print(Party[Individual])

Step 9: Stop

Explanation:

The algorithm begins here

Step 1: Start

This gets the political parties as a list

Step 2: Parties = [All delegates in the party]

This counts the number of delegates i.e. the length of the list

Step 3: Lent = Count(Parties)

This initializes the first individual you come in contact with, to delegate 0 [list index begins from 0]

Step 4: Individual = 0

The next person on the list is set to index 1

Step 5: Index = 1

This begins an iteration

Step 6: For I in Lent:

If Parties[Individual] greets, shakes or smile to Party[i]

Step 6.1: If Parties[Individual] == Parties[I]:

Then they belong to the same party. Increment count by 1

Step 6.1.1: Index = Index + 1

If otherwise

Step 6.2: Else:

This checks if the first person is still in check

Step 6.2.1 If Index == 0:

If yes, the iteration is shifted up

Step 6.2.2: Individual = I

Step 6.2.3: Index = 1

If the first person is not being checked

Step 7: Else

The index is reduced by 1

Step 7.1: Index = Index - 1

This prints the highest occurrence party

Step 8: Print(Party[Individual])

This ends the algorithm

Step 9: Stop

The algorithm, implemented in Python is added as an attachment

<em>Because there is an iteration which performs repetitive operation, the algorithm running time is: O(n) </em>

Download txt
You might be interested in
Adam receives an email from his bank telling him there is a problem with his account. The email provides instructions and a link
Georgia [21]

Answer:

2 and 3

Explanation:

fill out all details because the email looks authentic

call the bank to determine if he email is authentic

hope this helps

8 0
2 years ago
Read 2 more answers
Assuming you can use infinite number of CPUS for performance improvements, what would be the maximum speed up when the paralleli
natita [175]

Answer:

correct option is D i.e. 20

Explanation:

Given data:

Parallelizable portion is  given as 95%

so remaining will be serial portion i.e. 5%

we know that, for infinite number of cpus, maximum speed is calculated as

v =\frac{1}{f}

where f denote serial portion = 5% = 0.05

v = \frac{1}{0.05}

v = 20

hence so for serial portion of 5%, maximum speed is 20

correct option is D i.e. 20

3 0
3 years ago
What is your first step in developing the database?
barxatty [35]

The first step in developing a database is simply to have a conversation (talk) to the employees or end users who will be using the database.

<h3>What is a database?</h3>

A database can be defined as an organized and structured collection of data that are stored on a computer system as a backup and are usually accessed electronically.

As a general rule, having a conversation (talk) to the employees or end users who will be using the database is the first step in developing a database.

Read more on database here: brainly.com/question/13179611

#SPJ12

8 0
2 years ago
When you configure a new linked mailbox user, you must specify a _______________ to identify the remote user account that has th
vazorg [7]
<span> You must specify a master account.</span>
7 0
3 years ago
9. Advantages of desktop publishing over traditional methods include
emmasim [6.3K]
The correct option is D.
Desktop publishing refers to the process of creating documents by using page laying outs skills on a desktop computer that is attached to a printer. Desktop publishing have many advantage over the traditional method and this include the unified work space and the increased flexibility which it offers.<span />
8 0
3 years ago
Other questions:
  • • What is the difference between primary storage, secondary storage, and off-line storage
    10·1 answer
  • Write a for loop to verify that your function is correctly returning the expected output for the radius values between 0 and 11.
    14·1 answer
  • When a computer is booted the checks the computer's components?
    7·1 answer
  • How does kinetic energy affect the stopping distance of a small vehicle compared to a large vehicle?
    14·2 answers
  • A colleague asks you to research a CPU for a new server that will run Windows Server 2019. He explains the server roles that he
    7·1 answer
  • Who's YouTube creator?
    10·2 answers
  • Which of the following is an example of tangible property?
    5·1 answer
  • One method of encoding messages is known as the "expanding square code". this method encodes message by placing the character of
    10·1 answer
  • Why isn't image display working on wacom tablet.
    8·1 answer
  • ANSWER ASAP!!! 12 POINTS!!!!! RIGHT ANSWERS ONLY
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!