2. [20 Pts] Problem Solving and Algorithm Design
Consider the following scenario and then develop an algorithm that uses divide and conquer to solve it
a) Suppose you have 9 coins and one of them is heavier than others. Other 8 coins weight equally. You are also given a balance. Develop and algorithm to determine the heavy coin using only two measurements with the help of the balance. Clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
b) Now, suppose you have n coins and one of them is heavier. You can assume that n is a power of 3. Generalize the algorithm you have developed in part (a) above for this case. Clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Determine the running time of the algorithm. Clearly show how you have arrived at the solution.

Answers

Answer 1

Algorithm with 9 coins: Divide, weigh, divide, weigh, determine heavy coin. Generalized algorithm: Divide, weigh, recurse until single coin remains.

a) Algorithm to Determine the Heavy Coin with 9 Coins:

Divide the 9 coins into three groups: Group A with 3 coins, Group B with 3 coins, and Group C with 3 coins.

Compare the weights of Group A and Group B using the balance:

a) If Group A and Group B balance each other, the heavy coin is in Group C. Proceed to step 3.

b) If Group A and Group B do not balance each other, the heavy coin is in the heavier group. Proceed to step 3.

Take the heavier group (either Group A or Group B) and divide it into two subgroups: Subgroup A1 with 1 coin and Subgroup A2 with 1 coin.

Compare the weights of Subgroup A1 and Subgroup A2 using the balance:

a) If Subgroup A1 and Subgroup A2 balance each other, the heavy coin is the remaining coin in the heavier group.

b) If Subgroup A1 and Subgroup A2 do not balance each other, the heavy coin is the heavier coin among the two.

b) Generalized Algorithm for n Coins (where n is a power of 3):

Divide the n coins into three equal groups: Group A, Group B, and Group C.Compare the weights of Group A and Group B using the balance:

a) If Group A and Group B balance each other, the heavy coin is in Group C. Proceed to step 3 recursively with Group C.

b) If Group A and Group B do not balance each other, the heavy coin is in the heavier group. Proceed to step 3 recursively with the heavier group.

Repeat step 2 with the remaining group until a single coin is left.

The remaining coin is the heavy coin.

Running Time Analysis:

In both algorithms, the coins are divided into three groups at each step, reducing the problem size by a factor of 3 in each recursive call. Since the number of coins is a power of 3, the depth of recursion will be log3(n). At each level of recursion, we perform two measurements using the balance. Therefore, the total number of measurements required will be 2 * log3(n). The running time complexity of the algorithm is O(log(n)) or logarithmic in terms of the number of coins.

learn more about Divide and conquer.

brainly.com/question/31421672

#SPJ11


Related Questions

What will print out when this block of Python code is run?

i=1
#i=i+1
#i=i+2
#i=i+3

print(i)

a. 1
b. 3
c. 6
d. nothing will print

Answers

When the given block of Python code is run, the output "1" will be printed. What does the code mean? In the given block of Python code, there is an integer variable named I with the initial value 1. Then, there are four lines of code where the value of i is increased by 1, 2, and 3 in the next three lines respectively.

However, all the lines with # symbol at the beginning are commented out. It means those lines are not executable, and the code won't run them. So, the value of I remains unchanged, which is 1. The last line of the code is a print statement that will print the current value of I, which is 1. Hence, the output of this code is "1".Answer: a. 1

Learn more about Python code at https://brainly.com/question/30846372

#SPJ11

Hello, I have a question about the data structure and algorithm:
Could you please help to explain the principle (how to run) of AVL
Tree and the cases related to the code in detail?
ps:(please no

Answers

AVL Tree is a type of balanced binary search tree that guarantees logarithmic time for searching, insertion, and deletion of nodes. The height of the tree is maintained to be O(log n) by self-balancing techniques to ensure that it remains optimal.

To do this, an AVL tree ensures that the difference in height between the left and right subtrees of a node is no more than.The algorithm maintains this by performing rotation operations on the tree.The AVL tree is named after Adelson, Velsky, and Landis, who developed it in 1962. The basic principle of an AVL tree is to ensure that it remains a balanced binary search tree.

A balanced binary search tree is a tree whose left and right subtrees have a difference in height of at most 1. This ensures that the time complexity of insertion, deletion, and searching operations remains logarithmic.AVL tree follows the following rules for self-balancing:

- Left-Left (LL): A single rotation is performed on the right of the node to balance the tree.
- Right-Right (RR): A single rotation is performed on the left of the node to balance the tree.
- Left-Right (LR): Two rotations are performed, first RR rotation is performed on the left child then LL rotation.

AVL Tree algorithm follows the following operations: Insertion: Insert a node in the tree in the same way as in a BST. After the insertion, check the balance of the node. If it is imbalanced, then the tree is rotated to balance it.2 Deletion:
Delete the node in the tree in the same way as in a BST.

AVL trees are used in a wide range of applications that require searching, insertion, and deletion of nodes in O(log n) time. Some of the applications are database indexing, IP routing, and in-memory databases.

To know more about balanced visit:

https://brainly.com/question/27154367

#SPJ11

using c++ programming language
A theatre sells seats for shows and needs a system to keep track of the seats they have sold tickets for. Define a class for a type called ShowTicket. The class should contain private member variables

Answers

Here's an example implementation of the ShowTicket class in C++:

#include <iostream>

#include <string>

class ShowTicket {

private:

   std::string seatNumber;

   bool sold;

public:

   ShowTicket(const std::string& seat) : seatNumber(seat), sold(false) {}

   std::string getSeatNumber() const {

       return seatNumber;

   }

   bool isSold() const {

       return sold;

   }

   void sellTicket() {

       sold = true;

   }

};

int main() {

   ShowTicket ticket("A12");

   std::cout << "Seat Number: " << ticket.getSeatNumber() << std::endl;

   std::cout << "Sold: " << (ticket.isSold() ? "Yes" : "No") << std::endl;

   ticket.sellTicket();

   std::cout << "Sold: " << (ticket.isSold() ? "Yes" : "No") << std::endl;

   return 0;

}

In this example, the ShowTicket class has two private member variables: seatNumber (to store the seat number) and sold (to indicate if the ticket is sold or not). The constructor takes a seat number as a parameter and initializes sold to false. The public member functions include getSeatNumber() to retrieve the seat number, isSold() to check if the ticket is sold, and sellTicket() to mark the ticket as sold.

In the main() function, an instance of the ShowTicket class is created with a seat number "A12". The seat number and sold status are then displayed. Finally, the sellTicket() function is called to mark the ticket as sold, and the updated sold status is printed.

Note: This is a basic implementation to demonstrate the concept. In a real-world scenario, you may need additional features and error handling depending on the requirements of the theater ticketing system.

You can learn more about C++ at

https://brainly.com/question/13441075

#SPJ11

augmented reality is a wearable computer with an optical head-mounted display (ohmd).
a. true
b. false

Answers

Augmented reality typically involves the use of a wearable computer with an optical head-mounted display (OHMD). The statement is true.

Augmented reality (AR) is a technology that overlays virtual elements onto the real world, enhancing the user's perception and interaction with their surroundings. One common implementation of AR involves the use of a wearable computer, which is a portable computing device that can be worn on the body. This computer is typically equipped with an optical head-mounted display (OHMD), which is worn on the user's head and allows them to see virtual objects superimposed onto the real world.

The OHMD serves as the visual interface for the augmented reality experience, providing the user with a view of the virtual elements integrated into their environment. It may consist of a pair of glasses or goggles that incorporate a display screen, sensors, and cameras. The display screen overlays computer-generated images onto the user's field of view, while the sensors and cameras gather information about the real world, enabling the system to accurately position and align virtual objects.

Overall, the statement that augmented reality is a wearable computer with an optical head-mounted display (OHMD) is true, as the OHMD is an essential component of the wearable computer system used to deliver augmented reality experiences.

Learn more about augmented reality here:

https://brainly.com/question/30613389

#SPJ11

a. Describe the roles of: 1) Top of Stack Pointer, 2) Current Frame Pointer, 3) Return Pointer
b. Describe how an while loop can be translated
c. What are Exceptions? Shortly describe how exception handling can be implemented

Answers

    a.

Top of Stack Pointer (TOS) tracks the top element in the stack.Current Frame Pointer (CFP) points to the current function's activation record.Return Pointer keeps track of the location to return after executing a function.

   b. While loops evaluate a condition before each iteration and execute the loop body as long as the condition remains true.

   c. Exceptions are unexpected events during program execution, and exception handling uses try-catch blocks to catch and handle these events.

a.

The Top of Stack Pointer (TOS) is a register that keeps track of the topmost element in the stack. It is used in stack-based architectures to push and pop values onto and from the stack.The Current Frame Pointer (CFP) is a pointer used in call stack management. It points to the current activation record or frame of a function. It helps in accessing local variables and parameters within a function.The Return Pointer is a mechanism used in function calls to keep track of the location to which control should return after the execution of a function. It is typically stored in a special register or on the stack.

b. A while loop can be translated into code using the following structure:

while (condition) {

   // Loop body

}

The condition is evaluated before each iteration, and if it evaluates to true, the loop body is executed. After the loop body, the condition is checked again, and the loop continues until the condition becomes false.

c. Exceptions are events that occur during the execution of a program, which disrupt the normal flow of the program. Exception handling is a mechanism used to catch and handle these exceptional conditions. It allows the program to gracefully recover from errors or exceptional situations.

Exception handling can be implemented using try-catch blocks. The code that might throw an exception is enclosed within a try block. If an exception occurs within the try block, it is caught by an associated catch block. The catch block contains code to handle the exception, such as logging an error message or taking corrective actions. Multiple catch blocks can be used to handle different types of exceptions. Finally, there can be an optional finally block that executes regardless of whether an exception occurred or not. This block is typically used for cleanup tasks or releasing resources.

Learn more about here:

https://brainly.com/question/32772119

#SPJ11

When executed, the infected program opens a window entitled "Happy New Year 1999!!" and shows a fireworks display to disguise its installation. True False

Answers

It cannot be assumed as a universal truth without specific context or knowledge about a particular program or malware.

Without further information, it is not possible to determine the accuracy of the statement. The behavior described in the statement could be true for a specific program or malware designed to display a fireworks display with the title "Happy New Year 1999!!" as a disguise. However, it cannot be assumed as a universal truth without specific context or knowledge about a particular program or malware.

Learn more about malware here: https://brainly.com/question/29786858

#SPJ11

Question 6: Command Line
The command line:
1. Allows us to use different commands together to solve
problems or answer questions.
2. Is only useful to interact with the network.
3. Is always more effe

Answers

The statement "Is always more effective than graphical user interfaces (GUIs)" is NOT true about the command line.

The command line is a text-based interface used to interact with a computer's operating system or specific programs. It offers several advantages and capabilities. Firstly, it allows users to execute various commands and utilities, combining them to solve problems or obtain specific information. This flexibility and scripting capability make it a powerful tool for automation, batch processing, and system administration tasks. Secondly, the command line is not limited to network interactions; it can be used to manage files, install software, perform system configurations, and execute a wide range of commands and programs.

However, it is not accurate to claim that the command line is always more effective than graphical user interfaces (GUIs). GUIs provide intuitive visual interfaces that are often easier for novice users to navigate and interact with. GUIs can offer features like drag-and-drop functionality, visual feedback, and graphical representations, which can enhance usability and accessibility for certain tasks.

Learn more about (GUIs) here:

https://brainly.com/question/10247948

#SPJ11

Answer in Java. Include the code with a screenshot of the
execution please.
Write a class that has: - a member attribute that is an integer, a. The initial value of the attribute should be \( 4 . \) - a member method void Double() that doubles the value of a. - a member metho

Answers

Here's the Java code that satisfies the given requirements:

```java

public class MyClass {

   private int a; // Member attribute

   public MyClass() {

       a = 4; // Initialize the attribute with value 4

   }

   public void doubleValue() {

       a *= 2; // Double the value of 'a'

   }

   public void printValue() {

       System.out.println("The value of 'a' is: " + a);

   }

   public static void main(String[] args) {

       MyClass obj = new MyClass();

       obj.printValue(); // Output: The value of 'a' is: 4

       obj.doubleValue();

       obj.printValue(); // Output: The value of 'a' is: 8

   }

}

```

To execute the code, you can save it in a file named `MyClass.java`. Open a terminal or command prompt, navigate to the directory where the file is saved, and compile the code using the command `javac MyClass.java`. Then, run the compiled code using the command `java MyClass`. You should see the output as mentioned in the code comments.

To know more about Command Prompt visit-

brainly.com/question/32244337

#SPJ11

Example 19: Suppose the random variable X has E(X)=1.9 and V(X)=0.5 - Find E(3X+2). Select the closest to your unrounded answer: (A) 2 (B) 4 (C) 6 (D) 8 - Find V(−4X+8). Select the closest to your unrounded answer: (A) −8 (B) 0 (C) 8 (D) 16

Answers

To find the expected value E(3X+2), we can use the properties of expected values.
First, let's use the linearity property of expected values:[tex]E(aX+b) = aE(X) + b. In this case, a = 3 and b = 2.[/tex]
[tex]E(3X+2) = 3E(X) + 2[/tex]. Substituting the given value of E(X) = 1.9, we have:

[tex]E(3X+2) = 3(1.9) + 2 = 5.7 + 2 = 7.7.[/tex]

Since we need to select the closest unrounded answer, the closest option to 7.7 is (D) 8.
Now, let's find V(−4X+8), which represents the variance of the random variable −4X+8.
The variance V(−4X+8) can be calculated using the property[tex]V(aX+b) = a^2V(X), where a = -4.[/tex]
[tex]V(−4X+8) = (-4)^2 V(X) = 16V(X).[/tex]Substituting the given value V(X) = 0.5, we have:

[tex]V(−4X+8) = 16(0.5) = 8.[/tex]

Since we need to select the closest unrounded answer, the closest option to 8 is (C) 8.
In summary:
- E(3X+2) is closest to (D) 8.
- V(−4X+8) is closest to (C) 8.
To know more about unrounded visit:

https://brainly.com/question/13265426

#SPJ11

Please Make this java program without list<> interface
//##School.java##
package ;
import .List;
/*
* Many teachers, many students.
* Implements teachers an

Answers

The `getNumOfTeachers` and `getNumOfStudents` methods return the number of teachers and students in the school, respectively.Note: This is just one of the ways to implement teachers and students without using the List<> interface. There are several other ways to do it, and this is not the only correct answer.

Here's the Java program that implements teachers and students without using the List<> interface:```package com.example.school;
public class School {private Teacher[] teachersprivate Student[] studentsprivate int numOfTeachers;private int numOfStudents;
public School() {this.teachers = new Teacher[10];this.students = new Student[100];this.numOfTeachers = 0;this.numOfStudents = 0}public void addTeacher(Teacher teacher) {this.teachers[numOfTeachers] = teacher; numOfTeachers++;}
public void addStudent(Student student)this.students[numOfStudents] = student;numOfStudents++ }
public Teacher[] getTeachers() {return teachers;}
public Student[] getStudents() {return students;}
public int getNumOfTeachers() {return numOfTeachers;}
public int getNumOfStudents() {return numOfStudents;}}```

In the above Java program, the `School` class has two arrays of `Teacher` and `Student` objects, respectively. The `addTeacher` and `addStudent` methods add a teacher or a student to their respective arrays, and the `getTeachers` and `getStudents` methods return the entire arrays of teachers and students.

To know more about methods, visit:

https://brainly.com/question/5082157

#SPJ11

What information is relevant when deciding whether to laser tattoo fruits and vegetables instead of using paper or plastic stickers? (12)

Answers

When deciding whether to laser tattoo fruits and vegetables instead of using paper or plastic stickers, several factors should be considered. These include food safety, environmental impact, cost-effectiveness, durability, and consumer acceptance.

The decision to laser tattoo fruits and vegetables instead of using stickers involves assessing various relevant factors. Firstly, food safety is crucial. It is important to ensure that the materials used for tattooing are safe for consumption and do not pose any health risks. Secondly, the environmental impact should be considered. Laser tattooing can be a more sustainable option if it reduces the use of paper or plastic stickers, which contribute to waste.

Thirdly, cost-effectiveness is a key consideration. The equipment, maintenance, and operational costs of laser tattooing should be compared to the expenses associated with stickers. Additionally, the durability of the tattoos is important to ensure that they remain intact throughout the supply chain without causing damage or contamination. Finally, consumer acceptance plays a significant role. It is essential to gauge whether consumers are receptive to purchasing tattooed fruits and vegetables and whether it aligns with their preferences and expectations. Taking all these factors into account will help make an informed decision regarding the use of laser tattooing on produce.

To learn more about environmental impact; -brainly.com/question/13389919

#SPJ11

an ASM chart that detects a sequence of 1011 and that asserts a logical 1 at the output during the last state of the sequence

Answers

An ASM chart with states S0, S1, S2, and S3 is designed to detect the sequence 1011 and assert a logical 1 at the output during the last state of the sequence.

Design a circuit to implement a 4-bit binary counter using D flip-flops.

An ASM (Algorithmic State Machine) chart is a graphical representation of a sequential circuit that describes the behavior of the circuit in response to inputs and the current state.

To design an ASM chart that detects a sequence of 1011 and asserts a logical 1 at the output during the last state of the sequence, we can use four states: S0, S1, S2, and S3.

In the initial state S0, we check for the first bit. If the input is 1, we transition to state S1; otherwise, we remain in S0. In S1, we expect the second bit to be 0.

If the input is 0, we transition to S2; otherwise, we go back to S0. In S2, we expect the third bit to be 1. If the input is 1, we transition to S3; otherwise, we return to S0.

Finally, in S3, we expect the fourth bit to be 1. If the input is 1, we remain in S3 and assert a logical 1 at the output; otherwise, we transition back to S0.

This ASM chart ensures that the sequence 1011 is detected, and a logical 1 is asserted at the output during the last state of the sequence.

If the input deviates from the expected sequence at any point, the machine transitions back to the initial state to search for the correct sequence again.

Learn more about sequence 1011

brainly.com/question/33201883

#SPJ11

Write multiple programs to illustrate parallelism in
nested, for barrier and no way
1) write the codes for all in c language
2) write the algorithms
3) please send complete code with output screenshot

Answers

1. Code for Parallelism in Nested Loops in C Language:
Parallelism in nested loops is the most fundamental example of parallel computing.

It involves one or more parallel loops embedded within another outer loop.

Here is a sample code that uses nested loops to demonstrate parallelism in C language.

#include <stdio.h>

#include <omp.h>

#define SIZE 10

int main() {

   int i, j;

   #pragma omp parallel for private(j)

   for (i = 0; i < SIZE; i++) {

       for (j = 0; j < SIZE; j++) {

           printf("(%d, %d) Thread ID: %d\n", i, j, omp_get_thread_num());

       }

   }

   return 0;

}

to know more about nested loops visit:

https://brainly.com/question/29532999

#SPJ11

/*
* Implement the min() and nodeCount() method for the BST shown
below.
* min() returns the min key in the BST
* nodeCount() returns the count of the nodes in the BST
* Your implementation can either

Answers

Binary Search Tree (BST) is a binary tree that obeys the property that the left sub-tree of a node contains only nodes with keys lesser than the node’s key.

To implement this, we can follow the code below:
public int min(Node root) {
 if(root.left == null) {
   return root.value;
 }
 return min(root.left);
}
nodeCount() returns the count of nodes in a BST. To implement this method, we will do a depth first search and add 1 for every node. We will do this recursively until we reach the leaf nodes of the BST. Below is the implementation:


public int nodeCount(Node root) {
 if(root == null) {
   return 0;
 }
 return 1 + nodeCount(root.left) + nodeCount(root.right);
}
Finally, we add the count of nodes in the left sub-tree, right sub-tree, and root node to get the total number of nodes in the BST.

To know more about Binary Search Tree visit :

https://brainly.com/question/30391092

#SPJ11

A computer-aided design (CAD) system automates the creation and revision of designs, using computers and sophisticated graphics software. The software enables users to create a digital model of a part, a product, or a structure, and make changes to the design on the computer without having to build physical prototypes.

If a company decides to use a CAD system, it is using which of the following strategies to promote quality?

Answers

By implementing a computer-aided design (CAD) system, a company is employing the strategy of "improving quality and precision in design and production".

CAD systems enable users to create and manipulate digital models of parts, products, or structures, allowing for efficient design revisions without the need for physical prototypes. This technology facilitates a more accurate representation of the final product, reducing errors and inconsistencies that may arise during the design process. CAD systems also enhance collaboration among team members, enabling real-time feedback and simultaneous modifications.

By automating the creation and revision of designs, CAD systems promote higher quality standards, increased precision, and improved overall efficiency in the design and production processes.

Learn more about CAD system: https://brainly.com/question/30036311

#SPJ11

Q4) Let the sequence is given as \( x[n]=\{1,4,1,4,3,3,2,2\} \) a) Compute the DFT coefficients \( X[k] \) of the given sequence using the Decimation-in-Frequency (DIF) Radix-2 FFT algorithm manually.

Answers

Given sequence is `x[n] = {1,4,1,4,3,3,2,2}`To find the DFT coefficients `X[k]` of the given sequence using the Decimation-in-Frequency (DIF) Radix-2 FFT algorithm manually, follow the below steps:

Step 1: Rearrange the given sequence `x[n]` in bit-reverse order.`x[n] = {1,4,1,4,3,3,2,2}`Rearrange as`x[n] = {1,2,3,4,1,2,3,4}`

Step 2: Split the rearranged sequence into two sequences:

Even indexed sequence: `{x[0], x[2], x[4], x[6]}`Odd indexed sequence: `{x[1], x[3], x[5], x[7]}`Even indexed sequence is `{1, 3, 1, 2}`Odd indexed sequence is `{4, 4, 3, 2}`

Step 3: Calculate the DFT coefficients for both even and odd indexed sequences recursively using the DIF Radix-2 FFT algorithm until we get to the base case of 2-point DFTs.DFT of even indexed sequence: `

[tex]X[k] = E[k] + W_8^n O[k][/tex]

k = 0, 1, 2, 3`Where,`

[tex]E[k] = 1 + 2 W_2^n k + 1 W_4^n k + 2 W_6^n k O[k][/tex]

= 4 + 2W₂ₙᵏ - 1W₄ₙᵏ - 2W₆ₙᵏ`

Using twiddle factors,`W₂ₙᵏ = e^(-j2πk/8)`

= `[tex]\cos\left(\frac{2\pi k}{8}\right) - j\sin\left(\frac{2\pi k}{8}\right) = W_4^n k = e^{-j\frac{2\pi k}{16}}[/tex]

= `[tex]\cos\left(\frac{2\pi k}{16}\right) - j\sin\left(\frac{2\pi k}{16}\right) = W_6^n k = e^{-j\frac{2\pi k}{24}}[/tex]

`= [tex]\cos\left(\frac{2\pi k}{24}\right) - j\sin\left(\frac{2\pi k}{24}\right)[/tex]

DFT of even indexed sequence is `E[k] = {7, -1 -j, -1 +j}`DFT of odd indexed sequence:

`X[k] = E[k] + W₈ₙᵏ O[k], k = 0, 1, 2, 3`Where,`

[tex]E[k] = 4 + 2 W_2^n k - 1 W_4^n k - 2 W_6^n k O[k][/tex]

= 4 - 2W₂ₙᵏ - 1W₄ₙᵏ + 2W₆ₙᵏ`Using twiddle factors,DFT of odd indexed sequence is `O[k] = {8, 4 + 2j, -4, -2 -2j}`

Step 4: Calculate the final DFT coefficients `X[k]` by combining the results of the even and odd indexed sequences using the DIF Radix-2 FFT algorithm.

`X[k] = E[k] + W₂ₙᵏ O[k], k = 0, 1, 2, 3, 4, 5, 6, 7`Using twiddle factors,

`[tex]W_2^n k = e^{-j\frac{2\pi k}{8}}[/tex]`

=[tex]\cos\left(\frac{2\pi k}{8}\right) - j\sin\left(\frac{2\pi k}{8}\right)[/tex]

DFT coefficients of the given sequence is `X[k] = {16, 2 - 2j, -4, 2 + 2j, 0, 2 - 2j, -4, 2 + 2j}

`Hence, the DFT coefficients `X[k]` of the given sequence using the Decimation-in-Frequency (DIF) Radix-2 FFT algorithm is `X[k] = {16, 2 - 2j, -4, 2 + 2j, 0, 2 - 2j, -4, 2 + 2j}`.

To know more about DFT coefficients visit:

https://brainly.com/question/31775663

#SPJ11

Complete the class template for "...":
template
class doIt {
private:
vector myArray;
size_t currentIndex;
public:
// ~~> Initialize class variables
doIt() ...
// ~~> Add T parameter to T object and assign back to T object.
T& operator+=(T& rhs) ...
// ~~> Add to this class doIt parameter class doIt. If this is
// smaller in the array, then make it equal to parameter array.
// if this is bigger than just the common element with
// parameter array.
doIt& operator+=( doIt& rhs) ...
// ~~> Return a handle to an element of the array and set the
// current index to i.
T& operator[](const size_t i) ...
// ~~> Compute the size of this array.
size_t size() ...
friend ostream& operator<<(std::ostream& os, doIt& rhs)
{
os << " array:" << endl;
size_t rhsSize = rhs.size();
for (size_t i = 0; i < rhsSize; ++i)
os << "[" << i << "] = " << rhs[i] << endl;
return os;
}
};
int main() {
doIt d1, d2, d3;
d1[0] = 52; d1[1] = -32;
d2[0] = 48; d2[1] = 31;
d3[0] = -49;
cout << "d1 " << d1 << "d2 " << d2;
d1 += d2;
cout << "d1 " << d1 << "d2 " << d2 << "d3 " << d3;
d3 += d2;
cout << "d2 " << d2 << "d3 " << d3;
}
/* OUTPUT:
d1 array:
[0] = 52
[1] = -32
d2 array:
[0] = 48
[1] = 31
d1 array:
[0] = 100
[1] = -1
d2 array:
[0] = 48
[1] = 31
d3 array:
[0] = -49
d2 array:
[0] = 48
[1] = 31
d3 array:
[0] = -1
[1] = 31
*/

Answers

This code defines a class doIt that handles an array of a generic type T. It includes overloaded operators += for both T and doIt types, [] to access elements of the array, and << to output the array elements.

#include <iostream>

#include <vector>

template<typename T>

class doIt {

private:

   std::vector<T> myArray;

   size_t currentIndex;

public:

   // Initialize class variables

   doIt() : currentIndex(0) {}

   // Add T parameter to T object and assign back to T object.

   T& operator+=(T& rhs) {

       myArray[currentIndex] += rhs;

       return myArray[currentIndex];

   }

   // Add to this class doIt parameter class doIt.

   // If this is smaller in the array, then make it equal to parameter array.

   // If this is bigger than just the common element with the parameter array.

   doIt& operator+=(doIt& rhs) {

       size_t size = std::min(myArray.size(), rhs.myArray.size());

       for (size_t i = 0; i < size; ++i) {

           myArray[i] += rhs.myArray[i];

       }

       if (myArray.size() < rhs.myArray.size()) {

           for (size_t i = size; i < rhs.myArray.size(); ++i) {

               myArray.push_back(rhs.myArray[i]);

           }

       }

       return *this;

   }

   // Return a handle to an element of the array and set the current index to i.

   T& operator[](const size_t i) {

       currentIndex = i;

       return myArray[i];

   }

   // Compute the size of this array.

   size_t size() {

       return myArray.size();

   }

   friend std::ostream& operator<<(std::ostream& os, doIt& rhs) {

       os << " array:" << std::endl;

       size_t rhsSize = rhs.size();

       for (size_t i = 0; i < rhsSize; ++i) {

           os << "[" << i << "] = " << rhs[i] << std::endl;

       }

       return os;

   }

};

int main() {

   doIt<int> d1, d2, d3;

   d1[0] = 52;

   d1[1] = -32;

   d2[0] = 48;

   d2[1] = 31;

   d3[0] = -49;

   std::cout << "d1 " << d1 << "d2 " << d2;

   d1 += d2;

   std::cout << "d1 " << d1 << "d2 " << d2 << "d3 " << d3;

   d3 += d2;

   std::cout << "d2 " << d2 << "d3 " << d3;

   return 0;

}

The main function demonstrates the usage of the class by performing various operations on doIt objects and printing the results.

learn more about array here:

https://brainly.com/question/13261246

#SPJ11

6. Given the Tree C++ class below, answer questions a) and b):
class Tree {
private:
char data:
Tree *leftptr, *rightptr:
public:
Tree (char newthing, Tree* L, Tree* R):
"Tree () {}
char RootData() { return data: }
Tree* Left({ return leftptr; } Tree* Right() { return rightptr: }
}:
a) Write a C++ function for the post-order traversal of a binary tree. Note 1: you can use any of the methods available on the Tree class inside the function. Note 2: it is easier to write a recursive function.
[1 marks]
b) Using a Queue as a supporting ADT, write a C++ function to print a Binary Tree by level, root first (aka Breadth-first traversal). The class declaration for the Binary Tree is listed below. Note: the queue should contain pointers to the Tree nodes. Do not write the queue class itself, nor its methods, just consider using the well-known methods Join(), Leave(), Front() and isEmpty().
[2 marks]
c) Draw a B-Tree with order 3, where the following elements were inserted in the following order: 21, 3, 4, 7, 23, 25, 6, 20, 1, 5, 2
(copy the Image in the blue answer book).

Answers

This function uses recursion to traverse the tree in post-order fashion. It first visits the left subtree, then the right subtree, and finally the root node. It prints the data of each node as it visits it.

a) Here is a C++ function for the post-order traversal of a binary tree:

void postOrderTraversal(Tree* root) {

 if (root == nullptr) {

   return;

 }

 postOrderTraversal(root->Left());

 postOrderTraversal(root->Right());

 cout << root->RootData() << " ";

}

b) Here is a C++ function to print a Binary Tree by level, root first (aka Breadth-first traversal) using a Queue as a supporting ADT:

void breadthFirstTraversal(Tree* root) {

 if (root == nullptr) {

   return;

 }

 queue<Tree*> q;

 q.push(root);

 while (!q.empty()) {

   Tree* current = q.front();

   q.pop();

   cout << current->RootData() << " ";

   if (current->Left() != nullptr) {

     q.push(current->Left());

   }

   if (current->Right() != nullptr) {

     q.push(current->Right());

   }

 }

}

This function uses a queue to traverse the tree level by level. It starts with the root node, pushes it into the queue, and then continues to pop nodes from the queue, printing their data and pushing their children (if any) into the queue.

c) Sorry, but I cannot draw the B-Tree as requested as I am a text-based AI language model and do not have the capability to create visual images.

Learn more about post-order fashion

brainly.com/question/14209715

#SPJ11

Subject – Design and Analysis of
Algorithms.[ Theory & Need Only simulation, not
coding part ]
Please solve this , show all the works .its must need
show work. you can have enough time to answe

Answers

In the field of computer science, the design and analysis of algorithms is an essential topic. It involves the creation of algorithms for solving complex problems and analyzing their performance. Simulation is an important tool used in this area to test the effectiveness of the algorithm before implementation.


1. Design and analysis of algorithms is a crucial area of study in computer science that involves creating algorithms for solving complex problems and analyzing their performance. This is done to find out the best solution to a problem.

2. Simulation is an important tool used in this area to test the effectiveness of the algorithm before implementation. This allows for the testing of different scenarios and analyzing the algorithm's performance in each scenario.

3. It is essential to analyze the performance of an algorithm before implementing it to ensure that it works efficiently. This can be done through various methods such as Big O notation and running time analysis.



The design and analysis of algorithms is an essential topic in the field of computer science. It is an area of study that involves creating algorithms for solving complex problems and analyzing their performance. The creation of algorithms is essential because it is what drives computer systems to solve problems in various industries.

Simulations are an important tool used in the design and analysis of algorithms. Simulation is the process of testing the algorithm before implementation. The primary purpose of this is to test the effectiveness of the algorithm in different scenarios.

It is essential to analyze the performance of an algorithm before implementing it to ensure that it works efficiently. This can be done through various methods such as Big O notation and running time analysis.

Big O notation provides a way of measuring the efficiency of an algorithm in terms of how long it takes to execute. Running time analysis is another method used to analyze the performance of an algorithm, and it involves analyzing the time complexity of the algorithm.

In conclusion, the design and analysis of algorithms is an essential topic in computer science. It involves the creation of algorithms for solving complex problems and analyzing their performance.

Simulation is an important tool used in this area to test the effectiveness of the algorithm before implementation, and it is essential to analyze the performance of an algorithm before implementation to ensure that it works efficiently.

To learn more about Simulation

https://brainly.com/question/2166921

#SPJ11

Write a program in C to find the largest element using pointer. Test Data : Input total number of elements(1 to 100\( ) \) : 5 Number 1: 5 Number 2: 7 Number \( 3: 2 \) Number 4: 9 Number 5: 8 Expecte

Answers

In order to write a C program to find the largest element using pointer, you need to follow the steps below: Take input from the user and store it in an array using a loop. Keep a variable named "largest" to store the largest value in the array. Then, using pointers, compare each element in the array with the variable largest to find the largest value.

Finally, display the largest value on the screen. Here is the program: Code: Explanation: In the above code, we first declared the variables i, n, *ptr, and largest. Here, ptr is a pointer variable that will point to the base address of the array. The user is then prompted to input the total number of elements and then enter the elements one by one. The loop will then store the user's inputs in the array.

Next, we initialize the largest variable to the first element of the array. Using a for loop, we traverse through the array using the pointer ptr and compare each element with the largest variable. If the element is greater than the largest, then we update the value of largest with the current element. Finally, we print the largest value on the screen. I hope this helps!

To know more about pointer visit :-

https://brainly.com/question/31665795

#SPJ11

What is the goal of do-it-yourself testing?
a)
decide if the site or app is ready to go live
b)
it tests integration of all developers part
c)
making sure that the user goals are being met
d)
determine what needs to be fixed before the next session
2. According to Krug, you should have only users from your target audience test your site or app.
True or False
3.
It is more important to test Websites late in the development process.
a) True
b) False
4.
The focus of do-it-yourself testing is finding qualitative problems with a site or app.
a) True
b) False
5.
Pros and cons of the different recording techniques for user testing are completely different from those associated with data collection, discussed in Mod 2.
True
False
6.
When the testing process is followed by only one design iteration, the average improvement in usability is:
a)
22%
b)
100%
c)
38%
d)
17%
7.
While it is very helpful to facilitators and observers, sometimes users feel weird talking out loud regarding their thoughts and actions. A reasonable alternative to this is:
a)
constructive interaction
b)
integration testing
c)
have the user record their thoughts on paper
d)
screen capture software
8.
Who should have control during any testing scenario?
a)
Observers
b)
The Facilitator
c)
The user
d)
Project Managers
e)
TQA Manager
9.
Observers in the testing environment should say nothing.
True
False

Answers

According to the given statement 1-D, 2-true, 3-False, 4-True, 5-False, 6-38%, 7-Screen capture software, 8-User, 9-True (for more detail scroll down)  

1. The main goal of DIY testing is to determine if the site or app is ready to go live. This is accomplished by having end-users complete a set of tasks using the site or app and then providing feedback on their experience.

2. True. Steve Krug suggests that the target audience should be used to test the app or site. It is an important factor in making sure that the user goals are met.

3. False. The earlier you test a website in the development process, the better it is. Doing so would save you a lot of time and money.

4. True. The main focus of DIY testing is to find qualitative problems with a site or app.

5. False. Pros and cons associated with the different recording techniques for user testing are similar to those discussed in Mod 2, which is data collection.

6. c) 38%. The average improvement in usability when the testing process is followed by only one design iteration is 38%.

7. d) Screen capture software. While users find it difficult to talk out loud regarding their thoughts and actions, screen capture software can be used as an alternative.

8. c) The user. Users should be in control during the testing scenario as it provides more insights into the user's experience.

9. True. Observers should not say anything during the testing environment. It may influence the user's behavior, which is not what you want.

To know more about software visit :

https://brainly.com/question/32393976

#SPJ11

Write the preorder and postorder traversals of the given BST.
Include an explanation of the general difference(s) between the two
algorithms.

Answers

The given BST is not mentioned in the question. Therefore, the preorder and postorder traversals of a generic BST will be explained in detail as the difference(s) between the two algorithms.

Preorder TraversalPreorder traversal refers to a tree traversal algorithm that visits the root node first, then traverses the left subtree, and finally the right subtree in a recursive manner. The preorder traversal algorithm performs the following steps:Visit the root node of the tree. Print the value of the root node. Visit the left subtree of the tree. Traverse the left subtree in a recursive manner.Visit the right subtree of the tree. Traverse the right subtree in a recursive manner.The preorder traversal of a generic BST can be represented using the following example:Postorder TraversalPostorder traversal is a tree traversal algorithm that first traverses the left subtree, then the right subtree, and finally the root node in a recursive manner.

The postorder traversal algorithm performs the following steps:Visit the left subtree of the tree.Traverse the left subtree in a recursive manner.Visit the right subtree of the tree.Traverse the right subtree in a recursive manner.Visit the root node of the tree.Print the value of the root node.The postorder traversal of a generic BST can be represented using the following example:Difference between Preorder and Postorder Traversal AlgorithmsThe key difference between the two algorithms is the order in which the tree nodes are visited. The preorder traversal algorithm visits the root node first, then the left subtree, and finally the right subtree, while the postorder traversal algorithm visits the left subtree first, then the right subtree, and finally the root node.In addition, the two algorithms also differ in the order in which the tree nodes are printed. The preorder traversal algorithm prints the root node first, then the left subtree, and finally the right subtree, while the postorder traversal algorithm prints the left subtree first, then the right subtree, and finally the root node.

Learn more about preorder and postorder here;

https://brainly.com/question/32554959

#SPJ11

2. [20 pts] Factored FSMs: Design a Moore FSM that detects the following two input sequences: 0111 and 0011 . (a) [10 pts] First design the Moore FSM as a single complex Moore FSM. Show only the state transition diagram. (b) [10 pts] Now design the Moore FSM as a factored Moore FSM. Show only the state transition diagram. Hint: you might need an additional logic gate to produce the final output.

Answers

(a) Single Complex Moore FSM State Transition Diagram:

     ------[0]----

    |            |

--> q0 --[1]--> q1 --[1]--> q2 --[1]--> q3 (Accept)

    |    |

----[1]--|

    |

  (Reject)

In this diagram, q0, q1, q2, and q3 represent the states of the FSM. The arrows labeled with inputs [0] and [1] indicate the state transitions based on the inputs. The FSM starts in state q0 and transitions to q1 on input 0. From q1, it transitions to q2 on input 1, and from q2 to q3 on input 1, which represents the acceptance of the input sequence 0111. If any other input sequence is encountered, the FSM stays in q0 and rejects it.

(b) Factored Moore FSM State Transition Diagram:

scss

Copy code

    ----[0]---- [0] -----

   |                     |

--> q0 --[1]--> q1 --[1]--> q2 (Reject)

    |    |

----[1]--|

    |

 [0]/[1]

    |

   q3 (Accept)

In this factored FSM, q0, q1, q2, and q3 represent the states of the FSM. The arrows labeled with inputs [0] and [1] indicate the state transitions based on the inputs. The transition from q0 to q1 on input 1 remains the same as in the single complex FSM. However, for input 0, the FSM transitions to an intermediate state q2 which acts as a reject state. From q2, the FSM can transition to either q1 or q3 based on whether the input is 0 or 1. The final acceptance state is q3, which is reached when the input sequence is 0011.

You can learn more about FSM State Transition Diagram at

https://brainly.com/question/33340188

#SPJ11

In this course project you need to compile the principles of object-oriented programming in order to design and implement a graphical user interface application using JavaFX. The application is a food ordering application, where the user login to the system using a given username and password and land to a main panel which shows the menu items of the available dishes, and the user selects the items that he/she wishes to order, and the application prints out a bill that shows the order details. The main features:
1. A given text file "USERS.txt" contains username, password pairs of the registered users in the system, where the application reads the file from the beginning and creates an object for each user.
a. Design a User class that contains the properties and methods of the users.
b. The application parses the USERS.txt file and converts its content into an array of users objects.
2. A given file "MENU.TXT" contains the details of the available dishes in the restaurant such as (type, price, imageName, calories ...etc).
a. Design a Dish class that contains the properties and methods related to the restaurant dish.
b. The imageName property associated with each dish will point to an image file that the application will show in the panel.
c. The app reads the file and creates the menu in a GUI allowing the users to select the items they wish to order. 3. The app calculates the total price of the selected items and exports the order bill into a file.
4. Before closing the app, the app exports the inventory showing all the orders that have been ordered during that session.

Answers

Object-oriented programming (OOP) is a programming style that utilizes objects to accomplish tasks. This program comprises object-oriented principles for constructing and implementing a graphical user interface application that makes use of JavaFX.

It is a food ordering program in which a user logs in to the system using a given username and password and is presented with a primary panel that displays the available meal menu items. The user picks the items they want to order, and the app produces a bill showing the order information. The program has several features, including reading and parsing two given files to generate an array of user and dish objects, calculating the total price of the selected items, and generating an order bill file. At the end of the session, the program saves all of the orders produced during that session in an inventory file.

To know more about programming visit:

https://brainly.com/question/11023419

#SPJ11

if you would like to set a conditional formatting rule based on the function =or(g6="finance", h7<7000), which formatting rule type is needed?

Answers

If you would like to set a conditional formatting rule based on the function =OR(G6="finance", H7<7000), the formatting rule type needed is "Use a formula to determine which cells to format".

The Excel conditional formatting is an excellent tool for formatting a cell or a group of cells based on defined conditions. A condition is a set of rules that must be fulfilled to perform the formatting. Excel has several pre-built conditional formatting rules, including Highlight Cells Rules, Data Bars, Color Scales, and Icon Sets, among others. You may need to create a custom conditional formatting rule when none of the built-in rules meet your requirements. When you create a custom rule, you'll have access to the entire set of functions, including logical and comparison operators, that Excel provides. To create a custom formatting rule, do the following: Select the cell or range of cells you want to format. Choose "Conditional Formatting" from the "Styles" group in the "Home" tab of the ribbon. Select "New Rule" from the drop-down menu. Select "Use a formula to determine which cells to format. "In the "Format values where this formula is true" field, enter the formula =OR(G6="finance", H7<7000)Specify the formatting options you want to use (font color, background color, etc.).Click "OK" to create the rule, and click "OK" again to apply it.

To know more about conditional formatting  visit:

https://brainly.com/question/31475304

#SPJ11

T/F: In a relational table, each row is unique and uniqueness is guaranteed because the relation has a non-empty primary key value.

Answers

True. In a relational table, each row is unique and uniqueness is guaranteed because the relation has a non-empty primary key value.

A primary key is a column in a table that is used to uniquely identify each row of data. It must contain a unique value for each row and cannot have null values. No two rows in a table can have the same primary key value. If a table does not have a primary key, it is referred to as a heap. This means that the table is an unordered collection of rows with no guaranteed uniqueness. However, adding a primary key to a heap can improve performance by enabling the database management system to locate data more quickly.

Explanation: Every record in a relational database has a primary key. The primary key is a single or group of fields that uniquely identifies the record. The database system can only identify unique records by using the primary key. It is a field or combination of fields that have unique values for each record. In a table, a primary key column cannot be empty or null. It must contain unique values for each row. When we create a table in the database, it is necessary to include a primary key column. A table in a relational database is a collection of records. The rows in a table are also called records or tuples. The columns in a table are called fields or attributes.Conclusion:In conclusion, the given statement is true. In a relational table, each row is unique and uniqueness is guaranteed because the relation has a non-empty primary key value.

To know more about database visit:

brainly.com/question/30163202

#SPJ11

True or false, The Military Crisis Line, online chat, and text-messaging service are free to all Service members, including members of the National Guard and Reserve, and Veterans.

Answers

True. The Military Crisis Line, online chat, and text-messaging service are **free** to all Service members, including members of the National Guard and Reserve, and Veterans.

The Military Crisis Line, operated by the Department of Veterans Affairs, provides confidential support and crisis intervention 24/7. It is available to all Service members and Veterans at no cost. This includes the online chat service, which allows individuals to connect with trained professionals through instant messaging. Additionally, text-messaging support is also available for those who prefer this method of communication. These services aim to assist individuals who may be experiencing emotional distress, thoughts of self-harm, or other crises related to their military service. The availability of free and confidential support underscores the commitment to the well-being and mental health of Service members and Veterans.

Learn more about Service members here:

https://brainly.com/question/12274049

#SPJ11

Write a vhdl program that when x = 1, a timer will delay for 10
seconds and trigger y. (Don't use 'wait' function).

Answers

The following VHDL program implements a timer that delays for 10 seconds and triggers an output signal when the input signal x is equal to 1. This program uses a counter to keep track of the time.

To implement the timer functionality without using the 'wait' function in VHDL, we can use a counter and a clock signal. The counter will increment on every clock cycle, and when it reaches a certain value corresponding to 10 seconds, it will trigger the output signal y.

Here's an example VHDL code that demonstrates this:

```vhdl

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

entity Timer is

   port (

       x : in std_logic;

       clk : in std_logic;

       y : out std_logic

   );

end entity Timer;

architecture Behavioral of Timer is

   constant CLOCK_FREQUENCY : integer := 100_000_000; -- Assuming 100MHz clock

   constant TIMER_DELAY : integer := 10; -- 10 seconds delay

   signal counter : unsigned(31 downto 0);

   signal elapsed_time : unsigned(31 downto 0);

begin

   process(clk)

   begin

       if rising_edge(clk) then

           if x = '1' then

               counter <= counter + 1;

               if counter = (CLOCK_FREQUENCY * TIMER_DELAY) - 1 then

                   y <= '1'; -- Trigger output signal after 10 seconds

               end if;

           else

               counter <= (others => '0'); -- Reset the counter when x is not 1

               y <= '0'; -- Reset the output signal

           end if;

       end if;

   end process;

end architecture Behavioral;

```

In this VHDL program, we declare an entity `Timer` with three ports: `x` as the input signal, `clk` as the clock signal, and `y` as the output signal. The architecture `Behavioral` defines the behavior of the entity.

Inside the process, we use a synchronous design approach with the `rising_edge` function to detect the rising edge of the clock signal. When the clock edge occurs and `x` is equal to '1', the counter increments by 1.

We compare the value of the counter with the desired delay (10 seconds) by multiplying the clock frequency and the delay. Once the counter reaches the desired value, we set the output signal `y` to '1', indicating that the timer has completed.

If the input signal `x` is not equal to '1', the counter and the output signal are reset to their initial values.

By implementing this VHDL program in a suitable hardware platform, the timer will delay for 10 seconds and trigger the output signal `y` when the input signal `x` is equal to '1'.

Learn more about VHDL here:

https://brainly.com/question/33326835

#SPJ11

Write a program that uses nested loops to draw this pattern: $$$$$$$$ $$$$$$$ $$$$$$ $$$$$ $$$$ $$$ $$ $ Submit pycharm program (Must document program and explain what each line of code does)
need pycharm code

Answers

Here is a Python program that uses nested loops to draw the given pattern:

```python

# Step 1: Define the number of rows for the pattern

num_rows = 8

# Step 2: Use nested loops to draw the pattern

for i in range(num_rows, 0, -1):

   for j in range(i):

       print('$', end='')

   print()

```

The given program uses nested loops to draw the given pattern of dollar signs.

In the first step, we define the number of rows for the pattern using the variable `num_rows`. In this case, the pattern has 8 rows.

Next, we use a nested loop structure to draw the pattern. The outer loop, `for i in range(num_rows, 0, -1)`, iterates over the range of `num_rows` to 1 in reverse order, decrementing by 1 in each iteration. This loop controls the number of rows in the pattern.

Inside the outer loop, we have the inner loop, `for j in range(i)`, which iterates over the range from 0 to `i-1`. This loop controls the number of dollar signs to be printed in each row.

Within the inner loop, `print('$', end='')` is used to print a dollar sign without a newline character. This ensures that the dollar signs are printed in the same line.

Finally, `print()` is used outside the inner loop to print a newline character, which moves the cursor to the next line and starts a new row in the pattern.

This process continues until all the rows of the pattern have been printed.

Learn more about Python

brainly.com/question/30391554

#SPJ11

In a typical computer structure:

a. only serial buses exist.
b. serial and parallel buses both exist.
c. only parallel buses exist.

Answers

In a typical computer structure, (b) both serial and parallel buses exist. A bus is a set of wires, typically copper, that can transmit data and power across the various components of a computer.

The computer's components, such as the CPU and memory, are linked by a bus. A bus is a link between various subsystems of a computer, including the central processing unit (CPU), memory, and input/output (I/O) ports. Parallel and serial buses are two types of computer buses. Parallel buses transfer data in several bits at once over several wires. It means that numerous bits of data are transmitted simultaneously. On the other hand, serial buses transfer data one bit at a time over a single wire. It means that a single bit of data is transmitted at a time over the wire.

The majority of computers utilize both parallel and serial buses to transmit data. These buses are frequently combined and used for distinct purposes within a computer. For example, parallel buses may be used to transfer data between the CPU and memory, while serial buses may be used to transfer data to and from peripheral devices like printers and scanners.

Learn more about computer buses

https://brainly.com/question/29308794

#SPJ11

Other Questions
John is engaging in heterosexism. Which of the following does he believe?a. the assumption that heterosexuality is deviant.b. the institutionalization of heterosexuality as the only legitimate sexual orientation.c. the systematic denial of rights to homosexuals.d. the weakening of social norms related to sexual orientation. Program Specification: Build a hash table using chaining as the collision resolution technique. Insertions into the hash table will correspond to declarations of variables and values in a program, searches will be requests for the value of a variable. Some variables will be local and have a narrow scope while some variables will be global. The program will take input from a file, another program written in the omnipotent programming language BORG (Bionicly Omnipotent Resistance Grinders) and generate output from this program. The BORG language has the following commands (keywords): 1. START-FINISH blocks. Indicating different scopes. 2. COM - Single line comments: Text should be ignored if on the same line 3. VAR varName - Variable Declaration, adds "varName" to the hash table. 4. variable = expression - Assignment statements, ie GEORGE = 122. Find GEORGE in the hash table and assign 122 to it. 5.++ - increment operator, syntax: VARIABLE ++ 6. --- decrement operator, syntax: VARIABLE -- 7. expressions, expressions are limited to unary and binary arithmetic, or variable names 8. supported operators: + - /* % *(plus, minus, divide, multiple, modulo, exponent) 9. PRINT - syntax PRINT expression. If the expression is a variable, and this variable is not in scope, then an error message indicating unknown variable x at line number y. The value printed if there is a variable in scope should be the variable with the closest scope. 10. Errors - other than the print statements, our interpreter will not be responsible for detecting errors, syntax errors should be disregarded if encountered, assume that the source file is correct. Our hash function: sum the ordinal values of the characters of the variable multiplied by their position in the string (1- indexing), then taking the modulo by TABLESIZE. 1. The variable ABC = (65 * 1 + 66 * 2 +67 * 3) % TABLESIZE All tokens are separated by one space or a new line. Output: for this assignment, run your interpreter on this sample source program as well as a program of your own, and turn it the output from both, as well as the source code from your BORG program as well as source code of the assignment and its executable. Zip is good. Sample program and its output: Input Output COM HERE IS OUR FIRST BORG PROGRAM COM WHAT A ROBUST LANGUAGE IT IS START VAR BORAMIR = 25 VAR LEGOLAS = 101 PRINT BORAMIR BORAMIR IS 25 BORAMIR ++ PRINT LEGOLAS LEGOLAS IS 101 PRINT GANDALF GANDALF IS UNDEFINED PRINT BORAMIR 2 BOARAMIR 2 IS 52 COM COM NESTED BLOCK COM START VAR GANDALF = 49 PRINT GANDALF GANDALF IS 49 PRINT BORAMIR BORAMIR IS 26 FINISH PRINT GANDALF GANDALF IS UNDEFINED START LEGOLAS = 1000 PRINT LEGOLAS LEGOLAS IS 1000 FINISH PRINT LEGOLAS LEGOLAS IS 1000 LEGOLAS PRINT LEGOLAS LEGOLAS IS 999 FINISH how many pairs of ribs are attached anteriorly to the sternum Aill the empty comments below. int main () \{ int * ap, *bp; int a=2, b=5; ap= new int {a};/1 bp= new int {b};1/ *ap =a; I the value pointed by ap is bp=b;1/ the value pointed by bp is ap=a;1/ wrong (why?) /1 ap=&a;11 correct, ap is of a 11 previous memory pointed by ap is ap=bp;1/ the value pointed by ap is 11 ap is ap=10;1/ both ap and bp point to the value of bp /1 (why?) delete bp; // deallocate memory pointed by delete ap; // Is it correct (yes or no)? Why? \} The Democratic Alliance (DA) in Limpopo welcomes plans for the long-awaited commissioning of the Thohoyandou Taxi Rank in the 2021/22 financial year after long delays in the completion of the project. The intermodal building structure project which includes the taxi rank as well as a retail and office block commenced construction in June 2011. The facility has since had a plethora of issues and obstacles that have seen the project delayed and incur additional costs in remedial construction work. The initial cost of the Thohoyandou Taxi rank project was over R256 million and the department incurred a further R25.2 million in remedial construction works carried out on the project. The biggest issue the taxi rank construction project faced was that the building that reached practical completion in 2013 had shown cracks on the structure and had serious structural issues. A structural assessment by a structural engineer revealed numerous concerns regarding the structure of the building and that there was a need for remedial construction work to address the structural defects identified. The remedial work only commenced in 2017 (Anonymous, 2021). 1. What form of departmentalisation did the construction company responsible for building the taxi rank followed? Elaborate 10 Marks 2. 10 years and R256 million later, the rank has not been opened to public. Perform a control process to establish what went wrong and what could be the possible deviations. 30 Marks 3. Given that you are an operational manager from the municipality, what will be your solution to this predicament? 10 Marks 4. Who should be disciplined from the construction company and how? 10 Marks Please write the code for calculating 10th value of the Fibonacci series using recursive and iterative methods. ( 4 marks) if adh were not present, what would be the effect on urine concentration? In a breadth-first traversal of a graph, what type of collection is used in the generic algorithm? queue Ostack set Oheap An owner of real estate who engages a property manager to manage his property must receive a copy of the signed property management agreement when? Many developing countries are a. undermined by government corruption. b. rank among the least corrupt countries. c. have never had a significant problem with corruption. d. have had a significant problem with corruption in the 1930s. e. have no dealings with nations where corruption is high. A patient is having trouble abstaining from alcohol. Which drug is often prescribed to encourage abstinence?1. Librium (chlordiazepoxide)2. Thorazine (chlorpromazine)3. Antabuse (disulfiram)4. Wellbutrin (bupropion) Show that \( \rho \frac{D}{D t}\left(e+\frac{v^{2}}{2}\right)=\rho C_{p} \frac{\partial T}{\partial t} \) for ideal gus, incompressible flow which term describes a preliminary drawing done to scale in preparation for fresco painting? multiple choice question. A. plaster cast B. fresco C. secco D. sketch cartoon The movement of Humanism was set in motion by:O A. the introduction of mathematical principles into art.O B. rediscovery of Classical art and literature.O c. the increasing wealth of European artists.( D. new advances in artistic techniques. Consider the following system.The DNA transcription apparatusa)Describe the RELEVANT energy levels in one of its functions and its quantum origins. Your responses should be elaborate but punctual, as soon as possible.b) What considerations are necessary to describe the system you chose using partition functions? It is a common practice in object-oriented programming to make all of a class's data attributes accessible to statements outside the class. O True O False Evaluate C/(A)^B dt where A=4t2,B=3/2, and C=t2. Show all your steps clearly. Lab 6 - Subtract and Divide Fractions Modify Ch6Functions.cpp (which contains functions to Add and Multiply fractions) to include functions for Subtraction (2 points) and Division (2 points) of fractions. Test all functions (set, get, add, multiply, subtract, divide) at least 2 times (3 points). Provide all source code, each file containing a comment with your name, course code and date (2 points), and a screenshot of the run (1 point). Submit source code and screenshot together in a zip file.// Ch6Functions.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include using namespace std;void getFraction(double& x, double& y);void addFractions(double n1, double d1, double n2, double d2, double & nr, double & nd);void fractionToDecimal();void multiplyFractions();/* Exercise 9. Fraction handling program Menu:A. Add two fractionsB. Convert a fraction to decimalC. Multiply two fractionsD. Quit*/int main(){char cOption;cout Select a product or service that you enjoy or might like to study. Next, discuss three (3) methods to segment the market for that product/service by geographic, demographic, and psychographic characteristics. Your answer will include nine methods, three for each characteristic. Support your response with references and specific examples. Find limx[infinity] x^5 -15x^3 + 1 /100 -21x^2 9x^3