Answer:
<u>How to implement a stack in C using an array?</u>
A stack is a linear data structure that follows the Last in, First out principle (i.e. the last added elements are removed first).
This abstract data type can be implemented in C in multiple ways. One such way is by using an array.
Pro of using an array:
No extra memory required to store the pointers.
Con of using an array:
The size of the stack is pre-set so it cannot increase or decrease.
Answer:
// Producer Thread
void *producer(void *param) {
buffer_item item;
while (true) {
item = rand() % 100;
sem_wait(&empty);
pthread_mutex_lock(&mutex);
if (insert_item(item))
printf("Can't insert item\n");
else
printf("Producer %d: produced %d\n", *((int*)param), item);
pthread_mutex_unlock(&mutex);
sem_post(&full);
}
}
// Consumer Thread
void *consumer(void *param) {
while (true) {
buffer_item item = NULL;
if (in > 0)
item = buffer[in - 1];
sem_wait(&full);
pthread_mutex_lock(&mutex);
if (remove_item(&item))
printf("Can't remove item\n");
else
printf("Consumer %d: consumed %d\n", *((int*)param), item);
pthread_mutex_unlock(&mutex);
sem_post(&empty);
}
}
Explanation:
An outline of the producer and consumer threads appears as shown above.
Answer:
Answer written in python.
Explanation:
#ask user for the first integer.
first_number = int(input("enter first number: "))
#ask user for the second integer
second_number = int(input("enter second number: "))
#add both and store in a variable, result.
result = first_number + second_number
#print out the result
print ( f"the answer to the problem is {result} calculated by adding {first_number} to {second_number}")
The worded lines after the # sign are called comments and are used to describe what the following lines of code does making it easier to read and understand by other programmers or by the same programmer coming back to it after a while.
D. Data redundancy. This means the data is located in multiple places when it isn't necessary to do so.
Answer:
Option A; MINING THE SOCIAL MEDIA INPUTS.
Explanation:
Customer relationship management (CRM) is an approach to manage a company's interaction with current and potential customers. It uses data analysis about customers' history with a company to improve business relationships with customers, specifically focusing on customer retention and ultimately driving sales growth.
Social media mining is the process of obtaining big data from user-generated content on social media sites and mobile apps in order to extract patterns, form conclusions about users, and act upon the information, often for the purpose of advertising to users or conducting research.
The number listed from phone call would result in long distance charges to your phone bill, therefore, the issue of MINING THE SOCIAL MEDIA INPUTS should be addressed by the company to keep its CRM in line with your expectations.