Given an array A[0 … n-1], where each element of the array represent a vote in the election. Assume that each vote is given as an integer representing the ID of the chosen candidate. Can you determine who wins the election? What is the complexity of your solution? Hint: it is similar to finding the element that is repeated the maximum number of times.
In: Computer Science
/*
Array List
Modified from CS2 Software Design & Data Structures by Cliff Shaffer. OpenDSA
*/
#ifndef ALIST_H_RVC
#define ALIST_H_RVC
#include "List.h"
template // Array-based list implementation
class AList : public List {
private:
ListItemType* listArray; //Dynamic Array
(pointer)
int listSize; //Current number of list items
int curr; //Position of current element
int MAX_SIZE;
public:
//Constructors
AList() {
MAX_SIZE = 1000; // arbitrary
listArray = new
ListItemType[MAX_SIZE];
clear();
} //end constructor
// Create a new list element with maximum size
"MAX_SIZE" as a parameter
AList(int m) {
MAX_SIZE = m;
listArray = new
ListItemType[MAX_SIZE];
clear();
} //end constructor
bool isEmpty() const {
return listSize == 0;
}
void clear() { // Reinitialize the list
listSize = curr = 0; // Simply
reinitialize values
}
// Insert "it" at current position
// return value indicates success
bool insert(const ListItemType& it) {
if (listSize >= MAX_SIZE) return
false;
for (int i = listSize; i >
curr; i--) //Shift elements up
listArray[i] =
listArray[i - 1]; //to make room
listArray[curr] = it;
listSize++; //Increment list
size
return true;
}
// Append "it" to list
bool append(const ListItemType& it) {
cout << "\n\n******* This is
to be completed for the lab\n\n";
return true;
}
// Remove and return the current element
ListItemType remove() {
if (curr == listSize) curr--;
ListItemType it =
listArray[curr]; // Copy the element
for (int i = curr; i < listSize
- 1; i++) // Shift them down
listArray[i] =
listArray[i + 1];
listSize--; // Decrement size
if (curr > listSize) {
curr =
listSize;
}
return it;
}
void moveToStart() { curr = 0; } // Set to
front
void moveToEnd() { curr = listSize; } // Set to
end
void prev() { if (curr != 0) curr--; } // Move
left
void next() { if (curr < listSize) curr++; } //
Move right
int length() const { return listSize; } // Return list
size
int currPos() const { return curr; } // Return current
position
// Set current list position
to "pos"
bool moveToPos(int pos) {
if ((pos < 0) || (pos >
listSize)) return false;
curr = pos;
return true;
}
// Return true if current position is at end of the
list5
bool isAtEnd() const { return curr == listSize; }
// Return the current element
ListItemType getValue() const {
return listArray[curr];
}
bool find(const ListItemType& it) {
ListItemType curr =
cout << "\n\n*******
This is to be completed for the assignment\n\n";
return true;
}
bool findNext(const ListItemType& it) {
cout << "\n\n*******
This is to be completed for the assignment\n\n";
return true;
}
int count(const ListItemType& it) {
cout << "\n\n*******
This is to be completed for the assignment\n\n";
return 0;
}
};
#endif
Write the code for the find, findNext and count method in AList.h. This is an Array based list implementation problem in ADT, where we discuss about stacks
In: Computer Science
Choose an existing web site that you think can be improved or you have experienced problems with and explore the site thoroughly.
In: Computer Science
Find the K'th smallest element in an unsorted array of integers.
Find the K'th largest element in an unsorted array of integers.
please make two separate methods in java
In: Computer Science
C#
What to submit:
One zip file named Ass3.zip
This zip must contain one VS 2017 solution named Ass3, which contains one C# Windows Forms App project also named Ass3 and the project contains a default form, Form1.cs and Program.cs.
No change should be made in Program.cs, but your Form1 must be designed and implemented to satisfy the following requirements.
**Do not submit only a single file of the solution or project. The whole solution folder of VS 2017 must be zipped and submitted for grading.
Requirements:
In: Computer Science
What determines the capacity of an optical fibre strand?
In: Computer Science
Based on the statement, what are the possibilities that can happen to Uber Technologies Inc. autonomous vehicles Justify your answer. “Self-driving Uber kills Arizona woman in first fatal crash involving pedestrian”.
In: Computer Science
3. Write a Java program that generates a set of random strings from a given string of same length where no character is ever repeated and characters belong to the original string.
Examples
Input: “Hello World”
Output: “World oHlel”
In: Computer Science
use java Write a program that, given two binary numbers represented as strings, prints their sum in binary. The binary strings are comma separated, two per line. The final answer should not have any leading zeroes. In case the answer is zero, just print one zero i.e. 0
Input:
Your program should read lines from standard input. Each line contains two binary strings, separated by a comma and no spaces.
Output:
For each pair of binary numbers print to standard output their binary sum, one per line.
In: Computer Science
numbers = [75, 635, 274, 353, 534, 684, 381, 67, 968, 155, 502, 149, 10, 789, 757, 379, \
732, 386, 692, 473, 797,
272, 538, 703, 629, 179, 197, 521, 411, 590, 818, 892, 896, 951, 365, 800, 76\
7, 651, 584, 220, 584, 221,
23, 819, 794, 957, 74, 985, 395, 544, 324, 464, 980, 293, 980, 208, 560, 651,\
710, 21, 322, 968, 610,
947, 622, 369, 504, 113, 785, 119, 46, 332, 137, 865, 127, 333, 83, 403, 696,\
771, 733, 811, 220, 451,
559, 446, 895, 90, 591, 257, 506, 208, 432, 197, 16, 344, 261, 830, 115, 924,\
288, 442, 464, 213, 409,
815, 495, 205, -123, 147, 930, 69, 188, 419, 880, 815, 291, 646, 464, 888, 31\
0, 228, 529, 218, 565, 642,
315, 328, 288, 374, 208, 830, 834, 879, 75, 983, 112, 556, 736, 211, 582, 437\
, 717, 833, 719, 684, 518,
517, 744, 350]
I got to find average, maximum and minimum value from that given list in Python
In: Computer Science
A teacher needs list to fill student scores on five assignments.There are 15 students in her class.The students are numbered 1 through 15.Use nested for loops to print out the list for the teacher.
In: Computer Science
3D printing
What are the technical parameters such as range, speed,
capacity, etc. (if
applicable)?
o What are the strengths and weaknesses of the technology?
In: Computer Science
Write a Java application that inputs an unknown number of employees and determines and displays the gross pay for each employ. The company pays straight time for the first 40 hours worked by each employee (hours times rate), and straight time plus time-and-a-half for all hours worked in excess of 40 hours. Input the number of hours worked and hourly rate for each of the employees, then determine and display the employee’s gross pay. At the end of the program, print the total gross pay for all employees. Make sure you use the sentinel control Algorithm
In: Computer Science
Write a program that determines the probability of tossing a coin 10 times and getting exactly 0, 1, 2, 3, etc. heads. This is the binomial probability distribution. Store the probability in an array. You could get 0 heads or 10 heads or anything inbetween.
Use a for loop. The for loop will go from 0 to 10 inclusive. Use r as the number of successes. So r will go from 0 to 10. The probability of a success is .5, and also the probability of a failure is .5.
Print out in table form, column 1=r; goes 0 to 10, and then column 2; the probability of r.
Use 4 decimal places for the probability. You know if you get the correct answers because The sum of all the probabilities is 1.0, and all probabilities are in the range of 0 to 1 inclusive.
In C++, prefer visual studios but not required.
In: Computer Science
6. Why do you need to declare the data type of a variable before you can use it in Java? Give two (2) reasons
7. Is the World Wide Web and the Internet just two names for the same entity? Explain.
8. Why was it necessary to use the import statement when we used Scanner and Random?
9. Communication was a problem at Target. What would you recommend as an escalation process if someone encounters a threat and wants it to be known to upper management?
10. TCP is extremely reliable in delivering messages. Explain how this reliability is built into the message distribution process. Optional
11. The Operating System of a computer is the glue that bridges the hardware and software of a computer to make it work. Explain three (3) ways (features) the operating system provides to accomplishes that
. 12. Name the three (3) programming constructs we coded in class using Java along with a description of each one.
In: Computer Science