Program 1 Write a program that prints the first 12 Fibonacci numbers
Sample output:
1
1
2
3
5
8
13
21
34
55
89
144
Program 2 Write GCD both recursively and iteratively
Sample code:
https://www.freecodecamp.org/news/euclidian-gcd-algorithm-greatest-common-divisor/
Your output will simply be the GCD for the pair of numbers. Call your function with a few pairs and note in comments in your code the expected answer. The code must be (reasonably) valid Shank. You cannot use Java, C, JavaScript or some other language.
Tag: Programming
Lab help 1
Write a C program to run on ocelot called threadlab that uses 8 threads to increment a shared variable.
Each thread must loop 10 times, incrementing the shared variable by its Thread ID (tid) in every iteration of the loop. This number for the tid will be in single digits from 0-7.
Once a thread has finished looping, print the ID of the thread saying “Thread [ID] has finished.”
It is important to make use of mutexes so that only one thread is incrementing the shared variable at a time.
Output the value of the shared variable once all threads have finished incrementing it.
Before submission, make sure you clean up the directories so that no miscellaneous files are kept around in the submission. Include the source code and the Makefile in the submission.
Code should be nicely indented and commented.
Create a simple Makefile to compile your program into an executable called threadcircuit.
Take a screenshot of the screen showing the output on ocelot.
Submit your source file, the screenshot and your Makefile in one zip file
Case: NoVACatalog – I need an A in this. I will ask back my money if you bid on this and you can’t deliver within the set timeframe. .
It hasrecently put together a revised collection of items in a new catalog, which it is preparing to roll out ina mailing. In an attempt to grow its customer base, NoVA Catalog has recently joined aconsortium of catalog firms that specialize in computer and software products. The consortiumoffers members the opportunity to mail catalogs to names drawn from a pooled list of customers.Members supply their own customer lists to the pool, and can withdraw an equal number of nameseach quarter. Members are allowed to do predictive modeling on the records in the pool so they cando a better job of selecting names from the pool. NoVA Catalog is entitled to draw 200,000 names for amailing from a pool containing over 5,000,000 names.NoVA would obviously like to select the names that have the best chance of performing well, so itconducts a test—it draws 2,000 names from the pool and does a test mailing of the new catalog tothem. The data from this test mailing are in the NoVA Catalog worksheet. Along with some basicinformation about each individual (e.g., gender), the dataset contains information on the outcome ofthe mailing, i.e., whether the individual responded to the mailing, and if they did, how much theyspent. (Note that responding to the mailer implies making a purchase.)The descriptions of all the variables in the dataset are below:
Variable NameDescription CodeDescriptionSequence Sequence number of the record.SourceCodeIt is an indicator used by the consortium to identify where thename was drawn from. That is, each code represents the source ofthe record. Detailed description of the sources is not disclosed bythe consortium to the participating companies, however, somesources may contain more potential customers.US_Address Is the address of the customer a US address? 1: yes 0: noFrequency Number of transactions in last year.WebOrder Did the person place at least one order via web in the past?Male Is the person Male? 1: yes 0: noFemale Is the person Female? 1: yes 0: noRes_Address Is the address of the customer a residential address? 1: yes 0: noResponded Did the person respond to the test mail? 1: yes 0: noSpending Indicates the amount (in US Dollars) that someone responding tothe test mailing spent.Answer the following questions using the NoVA Catalog dataset.1. What percentage of people who received the test mailings made a purchase? (2)2. Of the customers who responded, what was the average purchase amount? (3)3. As indicated in the table above, some sources (captured by the SourceCode attribute) may containmore potential customers. Which are the top three sources of responders, i.e., which three sourcesgenerated the maximum number of customers? (5)4. Using the attributes that could be predictors, build a d e c i s i o n t r e e model i nR a p i d M i n e r that NoVA Catalog can use in the future to predict whether a catalog recipientwill respond. What is the dependent variable you used for the model? What are the independentvariables you used? (30)a. Based on your model, what is the best predictor of response (i.e., whether an individualwill make a purchase)? (4)b. Evaluate the predictive accuracy of the model using appropriate metrics. (6)Note:• You must clearly answer all the questions and provide RapidMiner screen prints tosupport your answer for Q1, Q2, Q3, Q4a, and Q4b. You will only receive half thepoints without screen prints even if your answer is correct.• You need to submit the RMP file for Q4 only. No need to submit RMP files for Q1, Q2,Q3.3Submission GuidelinesYour submission is to be made via Blackboard. The responses to all questions should besubmitted in a Word or Acrobat file. For each question, make sure you clearly answer thequestion that was asked.In addition to the response file, please submit the RapidMiner process file as evidence of yourmodel. That is, you need to submit the .rmp file only for Question 4.Make sure you attach all the necessary files before submitting the Exam.File Naming GuidelinesThe response file should be named as lastname.x, where lastname represents your last name, andx the file extension. For example, if Elaine Marie Benes submits her HW in pdf, then the fileshould be named Benes.pdf.Further, your full name must appear at the top of the response document (Word or pdf) itself. Donot compress any file.
Program activity
Call the executable memact.
Create pointers for a character, a string, an integer, a floating point number, an array of 10 integers, and a struct for a fraction.
For each pointer (6 of them), dynamically allocate the memory and then assign values as follows. You can use malloc and or calloc.Use a name for the string (array of characters).
Use 25 for the integer.
The character should be an ‘E’.
The floating point number should be 32.76
The array of integers should be the numerals 0 through 9.
The struct should have a numerator of 3 and a denominator of 4.
Print out values for all the dynamically allocated variables.
Free all dynamically allocated memory.
Output should look something like:
Character: EInteger: 25String: AlbertFloating Point: 32.76Array of Integers: 0 1 2 3 4 5 6 7 8 9Struct: 3/4Submit the image of the program running and of the actual code. You can paste them into a Word doc
Network Topology
What Does Networks Topology Mean?Networks topologies refer to the physical or logical layout of a network. It defines the way different nodes are placed and interconnected with each other. Alternately, the network topology may describe how the data is transferred between these nodes.
There are many types of network topologies: physical and logical. Physical topology emphasizes the physical layout of the connected devices and nodes, while logical topology focuses on the pattern of data transfer between network nodes.
Network TopologyThe physical and logical network topologies of a network do not necessarily have to be identical. However, both physical and network topologies can be categorized into five basic models:
Bus Topology: All the devices/nodes are connected sequentially to the same backbone or transmission line. This is a simple, low-cost topology, but its single point of failure presents a risk.
Star Topology: All the nodes in the network are connected to a central device like a hub or switch via cables. Failure of individual nodes or cables does not necessarily create downtime in the network but the failure of a central device can. This topology is the most preferred and popular model.
Ring Topology: All network devices are connected sequentially to a backbone as in bus topology except that the backbone ends at the starting node, forming a ring. Ring topology shares many of bus topology’s disadvantages so its use is limited to networks that demand high throughput.
Tree Topology: A root node is connected to two or more sub-level nodes, which themselves are connected hierarchically to sub-level nodes. Physically, the tree topology is similar to bus and star topologies; the network backbone may have a bus topology, while the low-level nodes connect using star topology.
Mesh Topology: The topology in each node is directly connected to some or all the other nodes present in the network. This redundancy makes the network highly fault-tolerant but the escalated costs may limit this topology to highly critical networks.
Network Topologies and the Physical Network
The earlier physical networks of computing at the end of the 20th century used these methods above to create these topologies explicitly. It’s fairly simple to envision the individual workstations being connected through Ethernet, or later through Wi-Fi, in a ring, star, tree, bus setup, or any of the other topologies mentioned. However, figuring out the best topology involves a detailed look at the goals and objectives and other setup factors for a given network.
Topologies and the Virtual Network
As the cloud became a place to keep data, run networks and deliver end-user services, the concept of virtualization took over the world of modern computing.
In a virtualized network, those traditional physical pieces of hardware are to an extent replaced by logical partitioned resources often called “virtual machines” that parcel out CPU and memory accordingly. With that in mind, the traditional network topologies might still be used, but they’re more logical than they are a way to characterize hardware setups. In other words, the logical topologies are built “on top of” the physical topologies that connect hardware.
In this type of modern network, the mesh topology, or a vibrant tree topology, would perhaps be more applicable and more popular. Where specific network destinations receive addresses and are dealt with as though they are individual nodes of the network, they’re more likely to be connected to many other nodes than they would have been in the early days when that required individual physical linking.
In addition, new best practices have evolved: for physical topologies, which include assessing the capability of systems to offer features like high bandwidth, large bisection capacities, and a greater number of alternative data paths. In the world of logical topologies, experts have begun to talk about “topology switching” as a means of dynamic customization for VLANs and other network setups.
Network Topology and Opacity
In the most modern systems, networks have become so complex that traditional topologies now apply in different ways. One of these phenomena is the use of opaque systems to foil hackers or outside cyberattacks. Some experts are now suggesting that by shielding the IP addresses and isolating different parts of the network into segments, companies can practice better cybersecurity hygiene. All of that continues to change how network topologies are used.
C Programming Homework.
Consider a system of 9 processes, P = {p1, …, p9}
Associated with the system are 6 memory cells, M = {M1, .., M6}
The domain and range for each process is given in the following table:
Process pi
Domain D(pi)
Range R(pi)
P1
M1, M2
M3
P2
M1
M5
P3
M3, M4
M1
P4
M3, M4
M5
P5
M3
M4
P6
M4
M4
P7
M5
M5
P8
M3, M4
M2
P9
M5, M6
M6
In addition, you are given the following precedence relation:
⇒= { (1,2) (1,3) (1,8) (1,9) (2,8) (2,9) (3,4) (3,8) (3,9) (4,5) (5,7) (5,9) }
(20pts) Construct the Precedence Graph (not containing any redundant or transitive edges)
(20pts) Determine if the system above is always determinate. If it is not, indicate which precedence relations are missing.
(30 pts) In the first problem, there were 9 processes, many of which were listed as pairs under the precedence relation. Suppose we are dealing with a system of only 5 processes named P1 through P5. You are given a set of constraints that are expressed by the following precedence relation:
⇒ = { (P1,P3), (P1, P5), (P2,P4), (P3, P4), (P4, P5) }
Provide pseudocode to show how you can use semaphores to enforce these constraints (i.e., the precedence relation ⇒).
4. (30pts) Implement a system of three processes (in C) which read and write sequence numbers to a file. Each of the three processes P1, P2, and P3 must obtain 50 integers from the file. The file only holds one integer at any given time. (This means that you will can only get one number at a time, and therefore must run the following steps in a loop. 50 times per process). Given a file, F, containing a single integer, each process must perform the following steps 50 times:
Open F
Read the integer N from the file
Close F
Output N and the process’ PID (either on screen or test file)
Increment N by 1
Open F
Write N to F (overwriting the current value in F)
Close F.
Will the numbers that are read by the processes P1, P2, and P3 be always unique, or do you observe duplicates of numbers being obtained by different processes (i.e., does a particular integer x appear in the output of more than on process)? Rewrite your implementation of these 3 processes to guarantee that no duplicate numbers are ever obtained by the processes. In other words, each time the file is read by any process, that process reads a distinct integer. Briefly describe why the code sequence above can lead to duplication of integer values and discuss how your solution will avoid these duplicates.
Your answer to this question should include: * The source to your programs (as an attachment) * A sample of the output demonstrating your program (In a PDF along with your other answers)
NOTE: Programs must compile and execute on the CSE machines. It is imperative that the file F containing in the integer is located on the local disk. On Linux, the /tmp directory is located on the local file system.
Data Structure and Algorithms
You must draw the diagrams showing the steps of the algorithms. You can do it by hand or digitally. While drawing the sequence of diagrams is a time-consuming task, they help you understand how to create your own algorithms for the lists. Please answer questions 1 through 6. In addition, the attached pdf can help on the maze question.
Algorithm to find exact matches in two strings
We have a string of characters from an alphabet of 4 letters {ACGT}. The string is G=3 bln
characters long. We have a 100 characters long string R from the same alphabet.
● How would you find all exact matches of the shorter string R in the long string G?
Describe the algorithm itself, not function calls.
hoare logic
using repeated addition, where
a and b are any two arbitrary numbers. Prove the program is correct using Hoare logic inference
rules (precondition and post condition have been given).
{b>=0}
x := b;
z := 0;
WHILE (x!=0) {
z := z a;
x := x-1;
}
{z=a*b}
start by identifying the loop invariant then apply the Hoare logic inference rules
To simulate process creation and destruction when implemented with linked lists.
I have provided the assignment details in the assignment.docx and also provided a skeleton program and thats how the format should be in skeleton.docx. The assignment should be In C language only. Please provide all files when done. There is also an example of how the output should be in the assignment.docs at the end.