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
The main workspace of a Windows computer is called the______
andrew11 [14]

Answer:

Desktop

Explanation:

8 0
3 years ago
What variable type is the output of a logical operator in labview?
Stella [2.4K]

Answer:

Boolean data types

Explanation:

consist of only two values i.e. true and false. It is a logical data type providing the output in the form of 0 or 1 specifying false and true respectively. The Boolean data type is indicated by green data wires. LabView stores the Boolean data as 8-bit values.

5 0
2 years ago
How to delete a brainly account?
dmitriy555 [2]

Answer:

Fill the deletion form go to settings and open FAQ ..

7 0
3 years ago
Read 2 more answers
Match the appropriate words to complete the paragraph.Wireless networks have no clear boundaries, therefore securing communicati
lawyer [7]

Answer:

a. Encryption.

b. Authentication.

c. Strong.

d. Rogue.

e. Insecure.

f. Hacking.

Explanation:

In Computer technology, authentication can be defined as the process of verifying the identity of an individual or electronic device. Authentication work based on the principle (framework) of matching an incoming request from a user or electronic device to a set of uniquely defined credentials.

Basically, authentication ensures a user is truly who he or she claims to be, as well as confirm that an electronic device is valid through the process of verification.

Encryption is a form of cryptography and typically involves the process of converting or encoding informations in plaintext into a code, known as a ciphertext. Once, an information or data has been encrypted it can only be accessed and deciphered by an authorized user.

Some examples of encryption algorithms are 3DES, AES, RC4, RC5, and RSA.

Wireless networks have no clear boundaries, therefore securing communications requires strong encryption, authentication, and strong protocols. One of the most common wireless security threats is the presence of rogue access points (APs). Rogue points can be set up for the benign purpose of free wireless access or for malicious purposes, such as gaining access to confidential data. Using an insecure wireless hotspot, like so many found in public settings, leaves you vulnerable to become the victim of hacking.

6 0
3 years ago
Who wants points cuz i got some
harina [27]
Me thank you very much
4 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following is a trademark automatically received by an organization when a symbol is being consistently used in the
    13·1 answer
  • ________ a database rearranges data and objects in a database to make its size smaller
    13·1 answer
  • What is a mortgage?
    8·2 answers
  • Define
    15·1 answer
  • What will empty the log of Internet sites you have recently viewed
    12·2 answers
  • Which type of approach grew out of the development of computers, where even complex behavior such as learning, remembering, cate
    5·1 answer
  • 1. Railroad tracks present no problems for a motorcyclist.
    8·1 answer
  • 7.2 code practice edhesive
    11·2 answers
  • Owen is writing a program that will lock his computer for one hour if the incorrect password is entered more than five times. Ha
    14·1 answer
  • When defining a system
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!