Reflect on how the concepts and material presented in this foundations of research course can be used in your future professional or academic endeavors. Include a specific example of a concept or assignment that you found most beneficial.
In: Computer Science
Please complete the following functions using C.
------------------------------------------------------------
#include
#include "dynarray.h"
/*
* This is the definition of the dynamic array structure you'll use for your
* implementation. Importantly, your dynamic array implementation will store
* each data element as a void* value. This will permit data of any type to
* be stored in your array. Because each individual element will be stored in
* your array as type void*, the data array needs to be an array of void*.
* Hence it is of type void**.
*
* You should not modify this structure.
*/
struct dynarray {
void** data;
int size;
int capacity;
};
/*
* This function should allocate and initialize a new, empty dynamic array and
* return a pointer to it. The array you allocate should have an initial
* capacity of 2.
*/
struct dynarray* dynarray_create() {
return NULL;
}
/*
* This function should free the memory associated with a dynamic array. In
* particular, while this function should up all memory used in the array
* itself (i.e. the underlying `data` array), it should not free any memory
* allocated to the pointer values stored in the array. In other words, this
* function does not need to *traverse* the array and free the individual
* elements. This is the responsibility of the caller.
*
* Params:
* da - the dynamic array to be destroyed. May not be NULL.
*/
void dynarray_free(struct dynarray* da) {
return;
}
/*
* This function should return the size of a given dynamic array (i.e. the
* number of elements stored in it, not the capacity).
*/
int dynarray_size(struct dynarray* da) {
return 0;
}
/*
* This function should insert a new value to a given dynamic array. For
* simplicity, this function should only insert elements at the *end* of the
* array. In other words, it should always insert the new element immediately
* after the current last element of the array. If there is not enough space
* in the dynamic array to store the element being inserted, this function
* should double the size of the array.
*
* Params:
* da - the dynamic array into which to insert an element. May not be NULL.
* val - the value to be inserted. Note that this parameter has type void*,
* which means that a pointer of any type can be passed.
*/
void dynarray_insert(struct dynarray* da, void* val) {
return;
}
/*
* This function should remove an element at a specified index from a dynamic
* array. All existing elements following the specified index should be moved
* forward to fill in the gap left by the removed element. In other words, if
* the element at index i is removed, then the element at index i+1 should be
* moved forward to index i, the element at index i+2 should be moved forward
* to index i+1, the element at index i+3 should be moved forward to index i+2,
* and so forth.
*
* Params:
* da - the dynamic array from which to remove an element. May not be NULL.
* idx - the index of the element to be removed. The value of `idx` must be
* between 0 (inclusive) and n (exclusive), where n is the number of
* elements stored in the array.
*/
void dynarray_remove(struct dynarray* da, int idx) {
return;
}
/*
* This function should return the value of an existing element a dynamic
* array. Note that this value should be returned as type void*.
*
* Params:
* da - the dynamic array from which to get a value. May not be NULL.
* idx - the index of the element whose value should be returned. The value
* of `idx` must be between 0 (inclusive) and n (exclusive), where n is the
* number of elements stored in the array.
*/
void* dynarray_get(struct dynarray* da, int idx) {
return NULL;
}
/*
* This function should update (i.e. overwrite) the value of an existing
* element in a dynamic array.
*
* Params:
* da - the dynamic array in which to set a value. May not be NULL.
* idx - the index of the element whose value should be updated. The value
* of `idx` must be between 0 (inclusive) and n (exclusive), where n is the
* number of elements stored in the array.
* val - the new value to be set. Note that this parameter has type void*,
* which means that a pointer of any type can be passed.
*/
void dynarray_set(struct dynarray* da, int idx, void* val) {
return;
}
In: Computer Science
in python
This is the animal speaking game. Print the following menu for your user:
------------------------------------
1) Dog
2) Cat
3) Lion
4) Sheep
5) Exit
Please enter a selection.
------------------------------------
If the user enters 1, print("Bark")
If the user enters 2, print("Meow")
If the user enters 3, print("Roar")
If the user enters 4, print("Baah")
If the user enters 5, exit the program.
define functions for each animal. For example:
def dog() :
def cat() :
and so forth ...
When called, each animal function should return a string associated with the animal.
For example, dog() should return "bark" and cat() should return "Meow".
In the main() function, if the user selects selection 1 for dog, call the dog() function and print the return value "bark"
Add error checking code to determine if the user enters a menu
number less than 1 or greater than 5. If so, tell the user
the
correct range of menu selections is 1 - 5.
Be sure to put your name and assignment number at the top of the program in comments.
You should implement the following functions and call them from the main() function
- getUserInput() which prints the menu and returns the user input to the main() function
- dog()
- cat()
- lion()
- sheep()
In: Computer Science
develop a multithreaded version of radix
sort
c language
In: Computer Science
Write a program that implements a stack of integers, and exercises the stack based on commands read from cin. To do this, write a class called Stack with exactly the following members:
class Stack { public: bool isEmpty(); // returns true if stack has no elements stored int top(); // returns element from top of the stack // throws runtime_error("stack is empty") int pop(); // returns element from top of the stack and removes it // throws runtime_error("stack is empty") void push(int); // puts a new element on top of the stack private: vector<int> elements; };
The program should read commands from cin until either end-of-file is reached or the command end is entered. (You can manually test for end-of-file by entering CTRL-D.) Each time the program expects a new command it should first print a prompt: "stack> "
Your program should catch all errors that happen and continue execution until the end command or end-of-file.
In case the command push is read, the program should read an integer value from cin and push it onto the stack. In case top is read, the program should print the top integer of the stack to cout. In case pop is read, the program should print the top integer of the stack to cout, and remove it from the stack. In case the command list is read, the program should print all values currently on the stack, without modifying the stack. (Exact format see below.)
Your program should check whether a "number" to be pushed is actually a number. If not, print an error message (see below), and reset cin such that it will again accept commands. (See Section 7.6 of the zyBook.) Also, your program should ignore all characters behind a number to be pushed that are on the same input line (example see below).
An example of a correct execution of this program is shown below:
stack> push 5 stack> pop 5 stack> pop error: stack is empty stack> push 6 stack> push 4bb stack> push foo error: not a number stack> list [4,6] stack> list [4,6] stack> top 4 stack> hello error: invalid command stack> end
You may want to use the compare() function (Links to an external site.) on a string to check which command has been entered.
Use of arrays, a built-in stack class, or container classes from std:: other than vector, is not allowed.
In: Computer Science
Task 2: Recursive Binary Search Part A - Target in list? Write a function simple recursive binary search(lst, target) which returns True if target is in lst; otherwise False. You must use recursion to solve this problem (i.e. do not use any loops).
Part B - Where is target? Write a function advanced recursive binary search(lst, target, lo, hi) which returns the index of an instance of target in lst between lo and hi, or None if target is not in that range. When first calling the function, lo = 0 and hi = len(lst)-1. You must use recursion to solve this problem (i.e. do not use any loops).
PYTHON CODE
In: Computer Science
/*
A right-angle triangle with integer sides a, b, c, such as 3, 4, 5,
is called a Pythagorean triple. The condition is that hypotenuse to
power of 2 is equal to adding of square of the 2 other sides. In
this example 25 = 16 + 9. Use brute force approach to find all the
triples such that no side is bigger than 50.
For this you should first implement the following Triangle class
and its methods. Then use it in main() to find all pythagorean
triples and put then in a std::vector. Finally print them out as
triples, like
(3, 4, 5)
.....
Make sure your output contains a triple only once, and not any
reordered ones, this means (3, 4, 5) is the same as (4, 3, 5) and
so only the increasing order triple should be printed out. This
means only (3, 4, 5) shoud be printed.
You program should print out all possible pythogorean triples with
sides <= 50.
*/
class Triangle
{
public:
Triangle(int a, int b, int c) // constructor.
Implement this
{}
bool isPythagorean() const // implement this
properly
{
return false;
}
private: // what do you put in private section?
}
int main()
{
}
In: Computer Science
For this assignment, you will apply what you learned in analyzing a simple Java™ program by writing your own Java™ program that creates and accesses an array of integers. The Java™ program you write should do the following:
Complete this assignment by doing the following:
Program Summary: This program demonstrates these basic Java
concepts:
* - Creating an array based on user input
* - Accessing and displaying elements of the array
*
* The program should declare an array to hold 10 integers.
* The program should then ask the user for an integer.
* The program should populate the array by assigning the user-input
integer
* to the first element of the array, the value of the first element
+ 100 to
* the second element of the array, the value of the second element
+ 100 to
* the third element of the array, the value of third element + 100
to
* the fourth element of the array, and so on until all 10 elements
of the
* array are populated.
*
* Then the program should display the values of each of the
array
* elements onscreen. For example, if the user inputs 4, the
output
* should look like this:
*
* Enter an integer and hit Return: 4
* Element at index 0: 4
* Element at index 1: 104
* Element at index 2: 204
* Element at index 3: 304
* Element at index 4: 404
* Element at index 5: 504
* Element at index 6: 604
* Element at index 7: 704
* Element at index 8: 804
* Element at index 9: 904
***********************************************************************/
package prg420week4_codingassignment;
// We need to import the following library if we want to use
the
// Scanner class to get user input.
import java.util.Scanner;
public class PRG420Week4_CodingAssignment {
public static void main(String[] args) {
// LINE 1. DECLARE AN ARRAY OF INTEGERS
// LINE 2. ALLOCATE MEMORY FOR 10 INTEGERS WITHIN THE
ARRAY.
// Create a usable instance of an input device
Scanner myInputScannerInstance = new Scanner(System.in);
// We will ask a user to type in an integer. Note that in this
practice
// code WE ARE NOT VERIFYING WHETHER THE USER ACTUALLY
// TYPES AN INTEGER OR NOT. In a production program, we would
// need to verify this; for example, by including
// exception handling code. (As-is, a user can type in XYZ
// and that will cause an exception.)
System.out.print("Enter an integer and hit Return: ");
// Convert the user input (which comes in as a string even
// though we ask the user for an integer) to an integer
int myFirstArrayElement =
Integer.parseInt(myInputScannerInstance.next());
// LINE 3. INITIALIZE THE FIRST ARRAY ELEMENT WITH THE CONVERTED
INTEGER myFirstArrayElement
// LINE 4. INITIALIZE THE SECOND THROUGH THE TENTH ELEMENTS BY
ADDING 100 TO THE EACH PRECEDING VALUE.
// EXAMPLE: THE VALUE OF THE SECOND ELEMENT IS THE VALUE OF THE
FIRST PLUS 100;
// THE VALUE OF THE THIRD ELEMENT IS THE VALUE OF THE SECOND PLUS
100; AND SO ON.
// LINE 5. DISPLAY THE VALUES OF EACH ELEMENT OF THE ARRAY IN
ASCENDING ORDER BASED ON THE MODEL IN THE TOP-OF-CODE COMMENTS.
}
}
In: Computer Science
Use Booth’s algorithm to multiply the 4-bit numbers, x and y, below, represented in twos complement. Show all your work.
In: Computer Science
please clear and direct anawar
Construct a B+ tree for the following set of key values under the assumption that the number of key values that fit in a node is 3.
Key values (3,10,12,14,29,38,45,55,60,68,11,30)
Show the step involved in inserting each key value.
In: Computer Science
Write a program that prints out the characters of a string each on a line and counts these characters. (Do not use the length function len() ).
In: Computer Science
There is many answer regarding this question on this website. So please I hope to get a new clear answer
E-commerce in Saudi Arabia has received a boost following the launch of several digital payment platforms in the last few years, a development that should support the growing number of online shoppers and contribute to government efforts to diversify the economy. Saudi Arabia is one of the fastest-growing markets in the Middle East for electronic payments, investments in the e-commerce market are set to rise under the government’s Vision 2030 strategy and National Transformation Programe (NTP), which both aim to improve communications connectivity and data transmission throughout the country as part of the broader diversification drive
. Answer the following questions:
1. What are the different methods of e-payment systems used in e-commerce platforms in Saudi Arabia?
2. Discuss the benefits of the multiple types of e-payment system to the customers?
3. Discuss the benefits of the multiple types of e-payment system to the e-commerce business?
4. What are some factors affecting the e-commerce business when choosing the e-payment gateways?
5. Explain some issues related to the e-payment system in the e-commerce platforms?
In: Computer Science
Hi,
I'm trying to make a basic GUI quiz in python using tkinter.
I would like the user to have to press a start button to begin the quiz and then be asked 5 different questions with the total score showing at the end. Ideally it would be a multiple choice quiz with the user having 4 different answers to choose from.
A very basic example of this would be appreciated so I can understand where exactly I'm going wrong.
Thanks in advance
In: Computer Science
In: Computer Science
/*
The following function receives the class marks for all student in
a course and compute standard deviation. Standard deviation is the
average of the sum of square of difference of a mark and the
average of the marks. For example for marks={25, 16, 22}, then
average=(25+16+22)/3=21. Then standard deviation = ((25-21)^2 +
(16-21)^2+(22-21)^2)/3.
Implement the function bellow as described above. Then write a test
console app to use the function for computing the standard
deviation of a list of marks that user inputs as floats in the
range of 0.f to 100.f. User signals end of the list by entering -1
as final mark. Make sure to verify user input marks are valid and
in the range, before processing them.
*/
float ComputeMarksStandardDeviation(std::array<float>
marks)
{
}
In: Computer Science