Operating System Management
In: Computer Science
FINISH print and freelist
#include<stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
struct node* insert(struct node* list,int d );
struct node* del(struct node* list,int d );
void print( struct node *list);
void freeList(struct node* list);
void copy ( struct node *q, struct node **s );
int main( ) {
int number = 0, choice = 0;
struct node *pList=NULL;
struct node *nList = NULL;
while(choice!= 4)
{
printf("Do you want to (1)insert, (2)delete, (3)Copy (4)quit.\n");
scanf("%d", &choice);
printf("Your choice is %d\n", choice);
if (choice == 1)
{
printf("Enter the value to insert\n");
scanf("%d", &number);
pList = insert(pList, number);
printf("Items in linked list: ");
print(pList);
printf("\n");
}
else if (choice == 2)
{
printf("Enter the value to delete.\n");
scanf("%d", &number);
pList = del(pList, number);
printf("Items in linked list: ");
print(pList);
printf("\n");
}
else if (choice == 3)
{
if (nList)
freeList(nList);
copy(pList, &nList);
printf("Items in NEW linked list: ");
print(nList);
printf("\n");
}
else
{
break;
}
}
freeList(nList);
freeList(pList);
printf("\nBye..\n");
return 0;
}
void copy ( struct node *source, struct node **dest )
{
if(source != NULL)
{
*dest = malloc(sizeof(struct node));
(*dest)-> data = source -> data;
(*dest) -> next= NULL;
copy(source->next, &((*dest)->next));
}
}
struct node* insert(struct node *list,int item)
{
if(list == NULL || item <= list->data)
{
struct node * pNew = (struct node *) (malloc(sizeof(struct node)));
pNew->data = item;
pNew->next = list;
return pNew;
}
list->next = insert(list->next, item);
return list;
}
struct node* del(struct node *list, int item)
{
if(list == NULL)
return NULL;
if(list->data == item)
{
struct node* rest = list->next;
free(list);
return rest;
}
list->next = del(list->next, item);
return list;
}
void print(struct node *list)
{
}
void freeList(struct node* list)
{
}
In: Computer Science
In C++ write a function to find a product of two matrices using arrays. The function should be general and should accept any size matrices.
In: Computer Science
Question 1 Draw a Entity Relationship Diagram
Snooty Fashions is an exclusive custom fashion designer business.
The Snooty Fashions Operations Database will keep track of the following:
Question 2 Draw a Schema Diagram with the same information.
In: Computer Science
Given the unordered array:
[0] |
[1] |
[2] |
[3] |
[4] |
[5] |
[6] |
[7] |
[8] |
P |
E |
R |
Y |
I |
H |
J |
L |
S |
Suppose this array were being sorted using the quick sort algorithm from the course content,
into ASCENDING order, with the left-most item as the pivot value.
List the letters in the resulting array, in order AFTER the FIRST PARTITIONING.
[0] |
[1] |
[2] |
[3] |
[4] |
[5] |
[6] |
[7] |
[8] |
In: Computer Science
The internet and other ICTs have played a key role in
transforming business. Write a report
analysing the impact of the internet and ICT on Disney World’s
business. Refer to the following elements in your report:
1. How the digital economy, including m‐commerce, has enabled
Disney World to
transform its business.
2. How Disney World has used MagicBands as part of an enterprise
system (ES) to exploit ICT.
3. How the Internet and related technologies, as disruptive
technologies, have assisted Disney World in improving customer
experiences.
In: Computer Science
In: Computer Science
Consider an array A[1 · · · n] which is sorted and then rotated k steps to the right. For example, we might start with the sorted array [1, 4, 5, 9, 10], and rotate it right by k = 3 steps to get [5, 9, 10, 1, 4]. Give an O(log n)-time algorithm that finds and returns the position of a given element x in array A, or returns None if x is not in A. Your algorithm is given the array A[1 · · · n] but does not know k. Use Java to solve this problem
In: Computer Science
Write a class named Rat (to simulate rational or fraction number) such that it works as in the main below.
int main()
{
Rat a(3, 4), b(1, 2);
a.print(); // output: 3/4
b.print(); // output: 1/2
Rat c = a.add(b);
c.print(); // output: 5/4
// Hint: 3/4 + 1/2 = 6/8 + 4/8 = 10/8 = 5/4
Rat d = a.multiply(b);
d.print(); // output: 3/8
// Hint: 3/4 x 1/2 = 3/8
return 0;
}
In: Computer Science
In: Computer Science
Modify your program from Learning Journal Unit 7 to read
dictionary items from
a file and write the inverted dictionary to a file. You will need
to decide on
the following:
* How to format each dictionary item as a
text string in the input file.
* How to convert each input string into a
dictionary item.
* How to format each item of your inverted
dictionary as a text string in
the output file.
Create an input file with your original three-or-more items and
add at least
three new items, for a total of at least six items.
------------------------------------------------------------------------------------------------------------------
The Unit 7 program:
Dr_Appointments = {'Mom':[2, 'April', 2020], 'Brother':[6, 'July', 2020], 'Sister':[6, 'January', 2021], }
def invert_dict(d):
inverse = dict()
for key in d:
val = d[key]
for val in val:
if val not in inverse:
inverse[val] =
[key]
else:
inverse[val].append(key)
return inverse
print('Dr. Appointments:', Dr_Appointments)
print('Inverted Dr. Appointments:')
Invert_Appointments = invert_dict(Dr_Appointments)
print(Invert_Appointments)
This is the expanded dictionary: the Unit 7 plus three more:
Mom: 2, April, 2020,
Brother: 6, July, 2020,
Sister: 6, January, 2021,
Aunt: 2, December, 2021,
Uncle: 6, November, 2021,
Niece: 2, December, 2020
In: Computer Science
One of the benefits of having our data structures be generalized to hold any type of data is that we can have data structures store instances of data structures. As we mentioned in class, a priority queue is a queue where entries are added (enqueued) according to their priority level (and in order when priority is tied). So the entry with the highest priority that was added to the priority queue the earliest would be at the front and would be the entry that is removed (dequeued).
Given that entries with the same priority will have to be organized in the order they were enqueued (first-in, first out), one possible option is to create a PriorityQueue that holds Queue objects. At the top level, the PriorityQueue can organize entries according to priority level and ensure that the separate priority groups are maintained in their proper order. At the next level, each component Queue would be responsible for all of the entries with the same priority level, and can maintain them in the order in which they were enqueued.
For this problem, assume that there are only 5 priority levels
(1 = very low; 2 = low;
3 = medium; 4 = high; 5 = very high). Give a detailed description
of how you could implement the PriorityQueue as described above.
Your answer should include:
How the top-level organization would work.
What properties your class would need.
A short description of how each of the three main queue operations (enqueue, dequeue,
and getFront) would work.
In: Computer Science
The header of a Python function is shown below:
def result(one, two, three = 3, four)
(a) How do we call the situation with the third parameter in this header?
(b) Indicate the method of correspondence between formal and actual parameters
that is used in the following function call:
result(four = 14, two = 22, one = 1, three = 33)
(c) Explain what is wrong with the following function call:
result(14, four = 44, 2, 3)
In: Computer Science
how docker provides an isolated workspace to keep applications on the same host or cluster isolated from one another
In: Computer Science
Consider the following statement: When designing a data structure, it is important to distinguish between what the characteristics and operations of the data structure are versus how they can be implemented.
(a) Explain why defining the ADT as a Java interface and defining classes to implement the interface is consistent with the above statement.
(b) Describe how the setup in part (a) is an example of polymorphism and provide a specific example of how polymorphism can be used to make our designed data structures more useful.
(c) Provide two (2) examples of how the specifications of the Java interface can enforce rules about how a data structure behaves. Be specific and explain your answer.
(d) Provide three (3) examples of how implementation-level decisions allowed a particular implementation to improve the runtime efficiency of an operation. Be specific and explain your answer.
In: Computer Science