#adjacency list implementation of graph in c
Explore tagged Tumblr posts
myprogrammingsolver · 1 year ago
Text
Simple Graph
For this computer assignment, you are to write a C++ program to implement several graph algorithms on simple graphs. These graphs are implemented with adjacency list representation. The `Graph` class is already defined in the header file `simplegraph.h` and included as part of this repository. The graph is created from a text file that contains the adjacency matrix representation of a graph. The…
Tumblr media
View On WordPress
0 notes
wuggen · 3 years ago
Note
why do graphs suck so much in rust :///
Because of ownership, mutability, and aliasing rules, all of which are in place to prevent double frees, use-after-frees, and data races.
To elaborate, a pretty straightforward way to implement a graph in, say, C++ would be something like the following:
template <typename T> class Node { T data; std::vector<Node<T>*> neighbors; };
Individually allocate each node and have them all store pointers to their neighboring nodes.
The problem with this design is that it is inherently memory-unsafe. Assuming a general graph structure (i.e. non-trees are permitted) then there's no clear hierarchy to the nodes, and so no clear way to delegate the deallocation of each node to another one. You gotta do that shit manually, and make sure you're not double-freeing or use-after-freeing or any of that. Probably you're gonna wanna depth-first traverse the entire graph and collect all of the node pointers into a single vector and then deallocate them from there; it's an involved process, very prone to error.
Trying to do a similar thing in Rust, we might try:
struct Node<T> { data: T, neighbors: Vec<Box<Node<T>>>, }
Problem with this is that Box is not interchangeable with a pointer; it can only have one owner, so that it's completely unambiguous when it needs to be deallocated and which Thing needs to do the deallocating, so that it happens automatically. But that means this structure only allows for directed trees. No cycles or back-edges allowed, that would mean the same Box<Node<T>> being owned by more than one other node!
Trying again, we might try to refcount the nodes:
struct Node<T> { data: T, neighbors: Vec<Rc<Node<T>>>, }
And that... kinda works, sometimes? It's a pain in the ass to construct, especially if you want cycles. Gotta juggle weak refs and shit, probably gonna need to add another field in there like weak_neighbors or something, which means also imposing a kinda pseudo-hierarchy anyway, and how do you manage that? Gonna run into a million and a half lifetime problems. Oh yeah, mutability is also a concern, could try sticking a RefCell in there, for even more of a headache.
I haven't even touched on how this shit might work in a multithreaded setting. Data races everywhere.
Anyway, I imagine since you sent this ask you're already painfully aware of all of these problems. But since you're here, might I suggest the following graph structure:
struct Graph<T> { nodes: Vec<(T, Vec<usize>)>, }
(Many variations exist, use your own discretion and ingenuity.)
This is basically an adjacency list representation. We've got all the nodes stored in one vec, owned by an overall graph structure, and each node is stored alongside a vec of indices into that same vec, indicating which nodes it has outgoing edges to. This is almost identical in spirit to the C++ example, except that we're using a kind of insulated memory space where every access is checked by necessity to make sure it's following the rules, and nothing has to worry about deallocating other things in the space because that's managed from outside. If you're not careful here you might run into some out-of-bounds access panics, but you won't run into any memory unsafety.
(Now, giving this structure a convenient public interface is another problem altogether.)
66 notes · View notes
codezclub · 8 years ago
Text
Write a C Program for Creation of Adjacency Matrix
Creation of Adjacency Matrix Write a C Program for Creation of Adjacency Matrix. Here’s simple Program for adjacency matrix representation of graph in data structure in C Programming Language. Adjacency Matrix:  Adjacency Matrix is a 2D array of size V x V where V is the number of vertices in a graph. Let the 2D array be adj[][], a slot adj[i][j] = 1 indicates that there is an edge from vertex i…
View On WordPress
0 notes
riskmanagementsoftwares · 3 years ago
Text
Right Angle Solution
Tumblr media
A right angle is an angle with at least three right angles. In other words, it's an angle that meets an adjacent side at an angle of 90 deg. The right angle is one of the largest angles in a right triangle. There are several methods to construct a right angle, but here are a few to get you started.
First, determine the angles and sides. Using the Pythagorean theorem, we can solve the right angle triangle. The two tangents to a right angle triangle are c and b. Using the Pythagorean theorem, we can find the unknown parts in terms of the known ones.
A right angle is an angle of 90 degrees, and obtuse angles are more than 90 degrees. The right angle solution is a 90 degree angle, as is a right angled triangle. You can find right angles in shapes like the letter "L". If you want Triarc Solutions, you can draw a triangle of that shape with two right angles.
In addition to the Pythagorean theorem, you can also apply a trigonometric relationship to find the missing side of a triangle. This is often called the angle of elevation or depression. You will need to know the angle's value to solve a right angle. You can also use a graphing calculator to find the angle's position in relation to the other sides.
Right Angle Solutions is a company that specializes in implementing custom solutions based on SAP Business Objects, Power BI, Tableau, and other BI solutions. It offers high-end BI solutions that are reliable, flexible, and scalable. Its team also provides a cloud migration process that is fast and easy. Learn more about staffing at https://en.wikipedia.org/wiki/Employment_agency.
Right Angle Solution at https://www.triarcsolutions.com/our-capabilities has been in business since 2014 and is one of the top suppliers of etc in India. It is based in Surat, Gujarat, and is listed on Trade India's list of verified sellers. The company also offers supreme quality etc. at very affordable prices. This makes it a great option for your needs.
For smaller applications, the EVL series is a smart option. It is space-saving, powerful, and offers high durability. The EVL planetary gearbox is the perfect solution for packaging automation, advanced conveyor systems, and assembly automation. Moreover, EVL planetary gearbox is an ideal choice for those who require precision and durability in a right angle solution.
1 note · View note
felord · 6 years ago
Text
CSCI203/CSCI803 ASSIGNMENT 3 Solved
This assignment involves an extension to the single source - single destination shortest path problem.  
The Program
  Your program should: Open the text file “ass3.txt”. (Note: “ass3.txt” should be a hardcoded as a constant.) Read a graph from the file. Find the shortest path between the start and goal vertices specified in the file. Print out the vertices on the path, in order from start to goal. Print out the length of this path and the total number of vertices visited. Devise a strategy for determining the second shortest path between the vertices. Find the second shortest path between the start and goal vertices specified in the file. Print out the vertices on the path, in order from start to goal. Print out the length of this path and the total number of vertices visited. Optimize your shortest and second shortest path algorithms to improve their performance. The data files are constructed as follows:   Two integers: nVertices and nEdges, the number of vertices and edges in the graph. nVertices triples consisting of the label and the x- and y-coordinates of each vertex. nEdges triples consisting of the labels of the start and end vertices of each edge, along with its weight. Note: the weight associated with an edge will be greater than or equal to the Euclidean distance between its start and end vertices as determined by their coordinates. Two labels, the indicating the start and goal vertices for which the paths are required.   A proposed solution to the second shortest path problem is as follows:   For each edge ei on the shortest path: Find the shortest path on (V, E – {ei}).    // shortest path without edge ei The shortest of these is the second shortest path.  
Questions
  Think about this! Is this proposed solution correct always? What if we require that the second shortest path be longer than the shortest path? What if the graph contains cycles? What if the graph is undirected? Explain your answers. If necessary explain how you might modify the proposed algorithm to address any issues that you identify.   Note: you may implement either the proposed solution or any modification you develop. You are not required to implement a modified proposal if you do not wish to do so.              
Step-1 (Week-10 demo, 2 marks)
For step 1, you should read the data file into adjacency lists, or an adjacency matrix, and print on the screen the first 5 vertices and the vertices they are connected to together with their weights. e.g.:   a:  c(35)  d(27)  e(48) b:  d(35)  g(27) c:  b(125) e(20)  f(56)  h(31)  . . . Note: The data shown above is for format purposes only.  
Step-2 (Discovering the Shortest Path) (2 marks)
For step 2, you should implement Dijkstra's algorithm and find the shortest path between the start and goal vertices specified in the input file. Print out the vertices on the path (in order from start to goal), the length of this path and the total number of nodes visited by the algorithm to discover the shortest path.  
Step-3 (Discovering the Second Shortest Path) (4 marks)
For step 3, you should devise a strategy for determining the second shortest path between the start and goal vertices specified in the file and implement your solution. Print out the vertices on the path (in order from start to goal), the length of this path and the total number of nodes visited by the algorithm to discover the second shortest path.  
Step-4 (Optimisation) (2 marks)
For step 4, implement the A* algorithm and repeat Step-2 and Step-3. Print the same information to show the improved performance.  
Step-5 (Report) (2 marks)
In a comment block at the bottom of your program (no more than 30 lines of text) list the data structures used by your program and describe your solution to the second shortest path problem. Also, provide answer to the questions. For this step, marks will be awarded based on accuracy and correctness.   Compilation: All programs submitted must compile and run on banshee: C:        gcc ass2.c    C++:      g++ ass2.cpp   Java:     javac ass2.java   Python: python ass2.py Programs which do not compile on banshee with the above commands will receive zero marks. It is your responsibility to ensure that your program compiles and runs correctly.                   Marking Guide: Marks will be awarded for the appropriate use of data structures and the efficiency of the program at processing the input and producing the correct output. Marks may be deducted for untidy or poorly designed code. Appropriate comments should be provided where needed. There will be a deduction of up to 4 marks for using STL, or equivalent libraries, rather than coding the data structures and algorithms yourself. You may use string or String type for storing words or text, if you wish. All coding and comments must be your own work.   Submission: Assignments should be typed into a single text file named "ass2.ext" where "ext" is the appropriate file extension for the chosen language. You should run your program and copy and paste the output into a text file named: "output.txt"   Submit your files via the submit program on banshee:  
             submit -u user -c csci203 -a 3 ass3.ext output.txt
              - where user is your unix userid and ext is the extn of your code file.   Late assignment submissions without granted extension will be marked but the points awarded will be reduced by 1 mark for each day late.  Assignments will not be accepted if more than five days late. An extension of time for the assignment submission may be granted in certain circumstances.  Any request for an extension of the submission deadline must be made via SOLS before the submission deadline. Supporting documentation should accompany the request for any extension. Read the full article
0 notes
programmingsolver · 6 years ago
Text
Computer Assignment 09 Simple Graph Solution
Computer Assignment 09 Simple Graph Solution
For this computer assignment, you are to write a C++ program to implement several graph algorithms on simple graphs. These graphs are implemented with adjacency list representation. The `graph` class is already defined in the header file `assignment09.h` and included as part of this repository.
The graph is created from a text file that contains the adjacency matrix representation of a graph. The…
View On WordPress
0 notes
freewhispersmaker · 8 years ago
Link
  Telecommunications & Network Management COMT6001 Assignment 1 To be handed in at the lecture on the 15th September, 2017 Q1 a) In the Telecommunications Act, describe what is meant by the term an Unbundled Local Loop (ULL)? In 1999 the ACCC made ULL a declared service – what is the meaning of a “declared service” under the Telecommunications Act and why is it important in promoting competition amongst Telecommunications Carriers? b) Name the two major Service Obligations and one Service Guarantee required of registered Telecommunications Carriers under the Telecommunications Act that implements the Social Policy of the Telecommunications Act and briefly state the purpose of each? c) Nominate which Australian Government Institution / Agency manage the following parts of the current Telecom 1997 Act and briefly describe their function with regard to the Australian Telecommunications market. 1) The Telecommunications Act 2) Telecom Market Entry 3) Price and Competition 4) Customer Complaints about telecommunications services 25% Q2 A microwave radio site has two 6.7 GHz, 298 Mbps microwave radio systems radiating from the site. The antenna type, bearing and the path length of each of the radio bearers are listed in this table. The Wanted to Interfering Unwanted ratio (W/U) required for co-channel operation is given in the attached 6.7 GHz Band Plan RALI and the antenna Radiation Pattern Envelopes are also attached. Radio System Antenna Type Bearing Path Length A HPX12-65 0° N 50 Km B HP8-65 30° N 25 Km a) Calculate the Received Signal Level for each of the two radio systems assuming that the Transmitter Power is 0.5 W, the RF cable losses are 3 dB for each RF feeder and the RF circulator/fixed losses for each antenna system is 3 dB. b) Calculate if there is sufficient W/U to allow each of the bearers to transmit on channel 4 (6720 MHz) without interfering with the receivers of the other radio bearers (you can allocate either polarisation for each bearer to achieve the required antenna discrimination). Draw a diagram of the possible interfering paths and show how you calculated the Wanted signal to Unwanted interfering signal ratio for each of the possible interfering paths. What frequency and polarisations would be required in this configuration? c) If the bearing of the radio system B is increased to 80° N calculate if both radio systems can now operate on channel 1? 25% Q3 Three Local Exchanges connect to the Primary Exchange via direct first choice routes with second choice routes provided via a Transit Exchange (see diagram below). The first choice Grade of Service (GoS) is set at 10% and the second choice GoS is set at 0.5%. For the amount of TCBH traffic shown in the diagram for each exchange: a) Calculate the number of circuits required on each of the first choice routes to meet the 10% GoS. b) Calculate the amount of traffic offered to each of the second choice routes and dimension the number of circuits on these routes (including the Transit to Primary exchange link) for the 0.5% GoS. c) If the Primary to Transit Exchange link fails for the busy hour, how many calls would be lost if the average call duration is 2.5 minutes? d) If the first choice route for Exchange 1 fails, how much traffic (in Erlangs) would be able to reach the Transit Exchange if the GoS for the duration of the outage is set at 10%? e) After six months of operation a TCBH traffic measurement is undertaken on the Transit Exchange to Primary Exchange route with the result of 14 Erlangs of TCBH traffic. What is the approximate GoS indicated by this traffic measurement, explain what that GoS indicates has occurred and what action, if any, should be taken by the network planner? 25% Q4 A Company has offices in Perth and Sydney generating the following levels of Time Consistent Busy Hour (TCBH) Telephone Traffic: PERTH SYDNEY Incoming PSTN Customer Calls 300 calls @ 3min average 600 minutes of calls Incoming PSTN Office Calls 100 calls @ 3.5min average 240 minutes of calls Outgoing PSTN Calls 200 calls @ 2.5min average 480 minutes of calls Inter-Office Calls 10E a) Dimension the minimum number of exchange lines from the Carrier Exchanges that need to be connected to the Perth and Sydney PABXs to carry the measured Incoming & Outgoing traffic for a Grade of Service of 0.5%. b) Dimension the minimum number of voice tie lines between Perth and Sydney required to carry the measured inter-PABX traffic for a Grade of Service of 0.5%, 1% and 10%. c) Draw a diagram of the above company network showing the number of exchange lines and inter-office tie lines connecting to the Perth and Sydney offices as dimensioned in parts (a) & (b) above? d) Assuming that all customer calls to the Perth & Sydney offices are routed by the Telephone Carrier’s network to the Perth office, re-dimension the PSTN exchange lines and voice tie lines so that the Sydney incoming customer call traffic can be answered in Sydney via the inter-office voice tie lines (Note: Sydney Incoming PSTN Office Calls & Outgoing PSTN calls continue to be connected via Sydney PSTN lines)? In this configuration what Grade of Service have you selected for the PSTN and voice tie line routes and explain why you have selected this GoS. 25% THE 6.7 GHz BAND (6425 – 7110 MHz) RF CHANNEL ARRANGEMENTS fo
ASSIGNMENT INSTRUCTIONS This band is designated for use by digital high capacity fixed point-to-point links. Typical Use : 40 MHz channels – 140 Mbit/s data : 80 MHz channels – 298 Mbit/s data Assignment Priority : 80 MHz channels – from highest channel downwards Minimum Path Length : 20 km Antenna Requirements : refer to Appendix 11 Note: 1. Proposed links need to be coordinated with licensed earth stations operating in this band. 2. The channel raster known previously as the interleaved raster has been removed. No new assignments are to be made. 3. Potential for interference to and from adjacent 6 GHz band fixed services. Reference 1. Rec. ITU-R F.384-5, “Radio-frequency channel arrangements for medium and high capacity analogue or high capacity digital radio-relay systems operating in the upper 6 GHz band”. [6.7 GHz – Page 1 of 3] FX 3 Appendix 1 – RF Channel Arrangements and Assignment Instructions October 2014 THE 6.7 GHz BAND (6425 – 7110 MHz) PROTECTION RATIOS 1. Protection ratios required between digital systems. Frequency Offset (MHz) PROTECTION RATIO (dB) Interferer Tx o Victim Rx 40 MHz p 40 MHz 40 MHz p 80 MHz 80 MHz p 40 MHz 80 MHz p 80 MHz 0 60 69 20 68 56 40 30 60 50 35 80 0 46 100 15 12 140 8 4 160 15 2. Protection ratios required between digital systems in the adjacent 6 GHz band. Frequency Offset (MHz) PROTECTION RATIO (dB) Digital Interferer Tx o Digital Victim Rx 40 MHz p 29.65 MHz 40 MHz p 59.3 MHz 80 MHz p 29.65 MHz 80 MHz p 59.3 MHz 55.21 12 70.035 20 75.21 15 84.86 1.5 90.035 24 104.86 10 Note: 1. Protection ratios for digital systems are based on a 50 km path length and PL (Percentage of time that the average refractivity gradient in the lowest 100 m of the atmosphere is less than or equal to -100 N units/km) of 20. For other path lengths and PL values refer to the protection ratio correction factors graph on the following page. [6.7 GHz – Page 2 of 3] FX 3 Appendix 1 – RF Channel Arrangements and Assignment Instructions October 2014
Source: © AcademicWritersBay.com
>> CLICK HERE TO ORDER 100% ORIGINAL PAPERS FROM AcademicWritersBay.com <<<</strong>
The post Telecommunications & Network Management COMT6001 appeared first on Academic Writers BAy.
0 notes
just4programmers · 8 years ago
Text
C++ STL Forward List Container – std::forward_list
In this tutorial you will learn about C++ STL forward list i.e., std::forward_list and operations, methods applicable on it.
Forward Lists come under sequence containers. Forward List implements singly linked list. Insertion, removal and moving operations are very fast than other containers. Every element of forward list contains its next element address. Main disadvantage of forward list is that cannot be iterated backwards and its individual elements cannot be accessed directly. When singly linked list preferred over double linked list, Forward list is better than List. Because list behaves a like double linked list. Example for where we can use forward list is chaining in hashing, adjacency list representation of graph etc.
Also Read: C++ STL List Container – std::list
C++ STL Forward List
Now let’s see what are the operations we can apply on forward list:
assign(): Just like insert method, assign() will store the values. By using assign() we can insert elements in two ways.
First way is we can insert what are the elements we required. Second way is we can insert a single element “n” number of times. But in second way of assignment list will be replaced by new values. Old list values will be erased.
Try this below code for more understanding:
#include<iostream> #include<forward_list> using namespace std; int main(){ forward_list<int> lst1; // declaration of a list forward_list<int> :: iterator it; // iterator for list // assigning values into list. lst1.assign({10,20,30}); for(it = lst1.begin(); it!= lst1.end(); ++it) cout << *it << " "; cout << endl; // using assign() method in other way lst1.assign(3,99); // assigning three elements of each value 99 for(it = lst1.begin(); it!= lst1.end(); ++it) cout << *it << " "; cout << endl; return 0; }
Output
10 20 30 99 99 99
Insert Functions
push_front(): This function used to insert new value at beginning of the list. The value from this function copied to the address before to the current first element of container.
emplace_front(): This function also used to insert elements at beginning of the container but there no copy operation. Here element directly inserts at the address before to the first element.
insert_after(): Using this function we can insert element at any position of the forward list. The arguments which we pass to this function will be copied to particular location.
emplace_after(): This also works same as insert_after() function. But element directly insert without any copy operation.
Example program to show above insert functions:
#include<iostream> #include<forward_list> using namespace std; int main(){ forward_list <int> lst1; forward_list <int> :: iterator it; forward_list <int> :: iterator it1; lst1.assign({10,20,30}); // initially these 3 values are in forward list // using push front method lst1.push_front(5); // using emplace_front to insert at front lst1.emplace_front(4); // check the result for(it= lst1.begin(); it!= lst1.end(); ++it) cout << *it << " "; cout << endl; // using insert_after function it1 = lst1.insert_after(lst1.begin(),99); // inserting 99 after current first element // using emplace_after function lst1.emplace_after(it1,0); // inserting 0 after which it1 iterator pointing to. // checking the result for(it = lst1.begin(); it!= lst1.end(); it++) cout << *it << " "; cout << endl; return 0; }
Output
4 5 10 20 30 4 99 0 5 10 20 30
Delete Functions
pop_front(): This function removes the first element of the forward list.
erase_after(): This function used to delete the element at particular position of forward list.
remove(): This function removes the specific element which we pass as an argument to this function
remove_if(): This function removes the element we specified only the condition which we gives is true.
Example program to show above erasing functions of forward list:
#include<iostream> #include<forward_list> using namespace std; int main(){ forward_list <int> lst1; forward_list <int> :: iterator it; lst1.assign({10,20,30,40,50}); // initially we assigned some values into forward list // deleting first element lst1.pop_front(); // deleting element at particular position using erase after function it = lst1.begin(); lst1.erase_after(it); // check the result for(it = lst1.begin(); it!= lst1.end(); ++it) cout << *it << " "; cout << endl; // deleting an element using remove function lst1.remove(50); // removing element 50 in forward list // deleting element by condition lst1.remove_if([](int a){ return a>25;}); // check the result for(it = lst1.begin(); it!= lst1.end(); ++it) cout << *it << " "; cout << endl; return 0; }
Output
20 40 50 20
Some more functions are:
splice_after(): This function used to transfer one forward list elements to other forward list. It places the elements after specified position only.
reverse(): This function reverse all elements of the forward list.
sort(): This function sorts the elements in the forward list.
Example program to explain above functions:
#include<iostream> #include<forward_list> using namespace std; int main(){ forward_list <int> lst1; forward_list <int> lst2; forward_list <int> :: iterator it; lst1.assign({20,40,60}); lst2.assign({30,50,70}); // now adding forward list1 elements to forward list2 using splice_after function after first element in this list lst2.splice_after(lst2.begin(),lst1); // Checking after adding forward list1 to forward list2 cout << "after adding forward list1 into forward list2" << endl; for (it= lst2.begin(); it!= lst2.end(); ++it) cout << *it << " "; cout << endl; lst2.reverse(); // preforming reverse operation on forward list2 // printing revere elements cout << "after reversing forward list2" << endl; for (it= lst2.begin(); it!= lst2.end(); ++it) cout << *it << " "; cout << endl; // sorting elements lst2.sort(); cout << "after sorting the elements" << endl; for (it= lst2.begin(); it!= lst2.end(); ++it) cout << *it << " "; cout << endl; return 0; }
Output
after adding forward list1 into forward list2 30 20 40 60 50 70 after reversing forward list2 70 50 60 40 20 30 after sorting the elements 20 30 40 50 60 70
Comment below if you have queries or found any information incorrect in above tutorial for C++ STL forward list.
The post C++ STL Forward List Container – std::forward_list appeared first on The Crazy Programmer.
0 notes
felord · 6 years ago
Text
FIT1045 Algorithms and programming in Python, S2 Assignment 1 Solved
Objectives
The objectives of this assignment are: To demonstrate the ability to implement algorithms using basic data structures and operations on them. To gain experience in designing an algorithm for a given problem description and implementing that algorithm in Python.
Submission Procedure
Save your files into a zip file called yourStudentID yourFirstName yourLastName.zip Submit your zip file containing your solution to Moodle. Your assignment will not be accepted unless it is a readable zip file. Important Note: Please ensure that you have read and understood the university’s policies on plagiarism and collusion available at http://www.monash.edu.au/students/policies/academic-integrity.html. You will be required to agree to these policies when you submit your assignment. A common mistake students make is to use Google to find solutions to the questions. Once you have seen a solution it is often difficult to come up with your own version. The best way to avoid making this mistake is to avoid using Google. You have been given all the tools you need in workshops. If you find you are stuck, feel free to ask for assistance on Moodle, ensuring that you do not post your code. Marks: This assignment will be marked both by the correctness of your code and by an interview with your lab demonstrator, to assess your understanding. This means that although the quality of your code (commenting, decomposition, good variable names etc.) will not be marked directly, it will help to write clean code so that it is easier for you to understand and explain. This assignment has a total of 12 marks and contributes to 10% of your final mark. For each day an assignment is late, the maximum achievable mark is reduced by 10% of the total. For example, if the assignment is late by 3 days (including weekends), the highest achievable mark is 70% of 12, which is 8.4. Assignments submitted 7 days after the due date will normally not be accepted. Detailed marking guides can be found at the end of each task. Marks are subtracted when you are unable to explain your code via a code walk-through in the assessment interview. Readable code is the basis of a convincing code walk-through.
Task 1: Strings (3.5 Marks)
Create a Python module called strings.py. Within this module implement the following three tasks. For this module you may not use the Python sequence method s.count(x). You may not import any other libraries or modules.
Part A: Code Breaker (1 Mark)
Write a function decode(string, n) that takes in an encoded message as a string and returns the decoded message. Input: a string string and a positive integer n. Output: the decoded string. The string is decoded by discarding the first n characters from the input string, keeping the next n characters, discarding the next n characters, and so on, until the input string is exhausted. There is no guarantee at which point in the decoding (keep or discard) the string will be exhausted. There is no guarantee that the length of string will be a multiple of n. Examples Calling decode(‘#P#y#t#h#o#n#’, 1) returns ‘Python’. Calling decode(‘AxYLet1x3’s T74codaa7e!’, 3) returns ‘Let’s code!’.
Part B: Pattern Finder (1 Mark)
Write a function pattern count(string, pat) that counts how many times a pattern occurs within a text. Input: a string string and a non-empty string pat, both comprising both upper and lower case alphanumeric and non-alphanumeric characters. Output: an integer count of the number of times pat occurs within string. The count is case sensitive. (See Example c.) Examples Calling pattern count(‘bcabcabca’, ‘abc’) returns 2. Calling pattern count(‘aaaa’, ‘aa’) returns 3. Calling pattern count(‘A long time ago in a galaxy far, far away...’, ‘a’) returns 8. Calling pattern count(‘If you must blink, do it now.’, ‘code’) returns 0.
Part C: Palindromes (1.5 Marks)
A palindrome is a word, phrase, or sequence that reads the same backwards as forwards. Write a function palindrome(string) that determines whether or not a given string is a palindrome. In order to receive full marks, the function must determine whether the alphanumerical characters create a palindrome (see Examples). Input: a string string comprising both upper and lower case alphanumeric and non-alphanumeric characters. Output: a boolean, True if the string when converted to lower case alphanumeric characters is a palindrome; otherwise False. Examples Calling palindrome(‘RacecaR’) returns True because ‘RacecaR’ reads the same backwards as forwards. Calling palindrome(‘66racecar77’) returns False because ‘66racecar77’ does not read the same backwards as forwards. Calling palindrome(‘Racecar’) returns True because ‘racecar’ reads the same backwards as forwards. Calling palindrome(‘Madam, I’m Adam’) returns True because ‘madamimadam’ reads the same backwards as forwards. Calling palindrome(‘#4Satire: Veritas4’) returns True because ‘4satireveritas4’ reads the same backwards as forwards.
Marking Guide (total 3.5 marks)
Marks are given for the correct behavior of the different functions: 1 mark for decode. 1 mark for pattern count. 5 marks if palindrome can correctly identify that a string with no processing is a palindrome (see Examples a and b), 1.5 marks if palindrome can correctly identify that a string when converted to lower case alphanumeric characters is a palindrome (see Examples c, d, and e).
Task 2: Friends (4.5 Marks)
You have been employed by Monash to analyse friendship groups on campus. Individuals have been allocated a number between 0 and the number of people on campus (minus one), and their friendships have been recorded as edges between numbered vertices. We assume friendships are always bi-directional. Monash has implemented this graph in a Python-readable format as both an adjacency matrix and an adjacency list. Create a Python module called friends.py. Within this module implement the following three tasks. Ensure you follow the inputs for each function correctly - one function takes an adjacency list, two functions take an adjacency matrix. You may not import any other libraries or modules.
Part A: Popular (1.5 Marks)
Write a function popular(graph list, n) that returns a list of people who have at least n friends. Each person is identified by the number of their vertex. Input: a nested list graph list that represents a graph as an adjacency list, that models the friendships at Monash; and a non-negative integer n. Output: a list of integers, where each integer is a person with at least n friends. If no person has at least n friends, return an empty list. The list may be in any order. Examples clayton_list = , , , , ] The example graph clayton list is provided for illustrative purpose. Your implemented function must be able to handle arbitrary graphs in list form. Calling popular(clayton list,2) returns . Calling popular(clayton list,3) returns . Calling popular(clayton list,0) returns .
Part B: Friend of a Friend (1.5 Marks)
Write a function foaf(graph matrix, person1, person2) that determines whether two people have exactly one degree of separation: that is, whether two (distinct) people are not friends, but have at least one friend in common. Input: a nested list graph matrix that represents a graph as an adjacency matrix, that models the friendships at Monash; an integer person1, and an integer person2, where 0 ≤person1, person2< number of people on campus, and person16= person2. Output: a boolean, True if the two people are not friends and they have at least one friend in common; otherwise False. Examples clayton_matrix = , , , , ] The example graph clayton matrix is provided for illustrative purpose. Your implemented function must be able to handle arbitrary graphs in matrix form. Calling foaf(clayton matrix,0,4) returns True as 0 and 4 are both friends with 2. Calling foaf(clayton matrix,0,3) returns False as 0 and 3 are friends directly. Calling foaf(clayton matrix,1,4) returns False as 1 and 4 have no friends in common.
Part C: Society (1.5 Marks)
Write a function society(graph matrix, person) that determines whether a person has two friends who are also friends with each other. Input: a nested list graph matrix that represents a graph as an adjacency matrix, that models the friendships at Monash; and an integer person, where 0 ≤person< number of people on campus. Output: a boolean, True if person has at least two friends who are also friends with each other; otherwise False. Examples Calling society(clayton matrix,0) returns True as 1 and 3 are both friends with 0. Calling society(clayton matrix,2) returns False as 2 is friends with 0 and 4, but 0 and 4 are not friends with each other.
Marking Guide (total 4.5 marks)
Marks are given for the correct behavior of the different functions: 5 marks for popular. 5 marks for foaf. 5 marks for society.
Task 3: Cards (4 Marks)
A friend of yours is developing a prototype for a website on which people can play poker. They have contacted you to help them implement some of the project’s backend: specifically, they would like some help telling what kind of hand a player has played. You have agreed to implement four functions to assist them. In the backend, your friend has decided to represent cards as tuples comprising an integer and a string: (rank, suit). For example, the seven of clubs would be represented as (7, ‘C’). As this is a prototype, your friend has told you that no face cards will be used (that is, rank is always an integer, where 2 ≤ rank ≤ 10, unless otherwise specified). There are four suits, with the following string representations: clubs: ‘C’, diamonds: ‘D’, hearts: ‘H’, spades: ‘S’. As this is poker, which is only played with one deck of cards, there will never be duplicates, and each hand will contain exactly five cards. Create a Python module called cards.py. Within this module implement the following four tasks. For this module you may not use the Python inbuilt function sorted() or the Python method list.sort(). You may not import any other libraries or modules.
Part A: Suits (1 Mark)
Write a function suits(hand) that sorts a given hand into the four suits. As there is no standard ranking of suits in poker, we will order alphabetically: clubs, diamonds, hearts, spades. Input: a list hand containing five cards. Output: a nested list containing four lists of cards, with each internal list corresponding to a suit. If there are no cards of that suit in the hand, the internal list for that suit is empty. Cards may be in any order within their suit-list.
Part B: Flush (1 Mark)
Write a function flush(hand) that determines whether a given hand is a flush. In poker, a flush is a hand that contains five cards of the same suit. Input: a list hand containing five cards. Output: a boolean, True if all five cards in hand are the same suit, False if not.
Part C: Straight (2 Marks)
Write a function straight(hand) that determines whether a given hand is a straight. In poker, a straight is a hand that contains five cards of sequential rank. The cards may be of different suits. Your friend has asked you an additional favour: they would like to use this function in various other games they may implement in the future, so instead of checking for a five-card straight, they would like you to check for an n card straight, where n is the number of cards in the hand. Like in poker, the cards may be of different suits. Input: a list hand containing at least three cards, where each card may have a rank of some number greater than zero. Output: a boolean, True if the ranks of the cards in hand may be ordered into an unbroken sequence with no rank duplicated, False if not.
Examples
Calling suits() returns , , , ]. As there are multiple clubs, the clubs cards may be in any order within their internal list. Calling flush() returns True. Calling flush() returns False. Calling straight() returns True. Calling straight() returns False. Calling straight() returns False. Calling straight() returns True as the ranks of the cards form an unbroken sequence, , with no rank duplicated.
Marking Guide (total 4 marks)
Marks are given for the correct behavior of the different functions: 1 mark for suits. 1 mark for flush. 1 mark for straight if it is able to handle a normal poker five-card hand with card ranks between 2 and 10 inclusive (see Examples d, e, and f); 2 marks for straight if it is able to handle an arbitrarily large hand with arbitrary ranks (see Example g). The functions may return True or False at your discretion for instances where person1 is person2. This case will not be marked. Read the full article
0 notes
myprogrammingsolver · 6 years ago
Text
Computer Assignment 09 Simple Graph Solution
Computer Assignment 09 Simple Graph Solution
For this computer assignment, you are to write a C++ program to implement several graph algorithms on simple graphs. These graphs are implemented with adjacency list representation. The `graph` class is already defined in the header file `assignment09.h` and included as part of this repository.
The graph is created from a text file that contains the adjacency matrix representation of a graph. The…
View On WordPress
0 notes
freewhispersmaker · 8 years ago
Text
Telecommunications & Network Management COMT6001
  Telecommunications & Network Management COMT6001 Assignment 1 To be handed in at the lecture on the 15th September, 2017 Q1 a) In the Telecommunications Act, describe what is meant by the term an Unbundled Local Loop (ULL)? In 1999 the ACCC made ULL a declared service – what is the meaning of a “declared service” under the Telecommunications Act and why is it important in promoting competition amongst Telecommunications Carriers? b) Name the two major Service Obligations and one Service Guarantee required of registered Telecommunications Carriers under the Telecommunications Act that implements the Social Policy of the Telecommunications Act and briefly state the purpose of each? c) Nominate which Australian Government Institution / Agency manage the following parts of the current Telecom 1997 Act and briefly describe their function with regard to the Australian Telecommunications market. 1) The Telecommunications Act 2) Telecom Market Entry 3) Price and Competition 4) Customer Complaints about telecommunications services 25% Q2 A microwave radio site has two 6.7 GHz, 298 Mbps microwave radio systems radiating from the site. The antenna type, bearing and the path length of each of the radio bearers are listed in this table. The Wanted to Interfering Unwanted ratio (W/U) required for co-channel operation is given in the attached 6.7 GHz Band Plan RALI and the antenna Radiation Pattern Envelopes are also attached. Radio System Antenna Type Bearing Path Length A HPX12-65 0° N 50 Km B HP8-65 30° N 25 Km a) Calculate the Received Signal Level for each of the two radio systems assuming that the Transmitter Power is 0.5 W, the RF cable losses are 3 dB for each RF feeder and the RF circulator/fixed losses for each antenna system is 3 dB. b) Calculate if there is sufficient W/U to allow each of the bearers to transmit on channel 4 (6720 MHz) without interfering with the receivers of the other radio bearers (you can allocate either polarisation for each bearer to achieve the required antenna discrimination). Draw a diagram of the possible interfering paths and show how you calculated the Wanted signal to Unwanted interfering signal ratio for each of the possible interfering paths. What frequency and polarisations would be required in this configuration? c) If the bearing of the radio system B is increased to 80° N calculate if both radio systems can now operate on channel 1? 25% Q3 Three Local Exchanges connect to the Primary Exchange via direct first choice routes with second choice routes provided via a Transit Exchange (see diagram below). The first choice Grade of Service (GoS) is set at 10% and the second choice GoS is set at 0.5%. For the amount of TCBH traffic shown in the diagram for each exchange: a) Calculate the number of circuits required on each of the first choice routes to meet the 10% GoS. b) Calculate the amount of traffic offered to each of the second choice routes and dimension the number of circuits on these routes (including the Transit to Primary exchange link) for the 0.5% GoS. c) If the Primary to Transit Exchange link fails for the busy hour, how many calls would be lost if the average call duration is 2.5 minutes? d) If the first choice route for Exchange 1 fails, how much traffic (in Erlangs) would be able to reach the Transit Exchange if the GoS for the duration of the outage is set at 10%? e) After six months of operation a TCBH traffic measurement is undertaken on the Transit Exchange to Primary Exchange route with the result of 14 Erlangs of TCBH traffic. What is the approximate GoS indicated by this traffic measurement, explain what that GoS indicates has occurred and what action, if any, should be taken by the network planner? 25% Q4 A Company has offices in Perth and Sydney generating the following levels of Time Consistent Busy Hour (TCBH) Telephone Traffic: PERTH SYDNEY Incoming PSTN Customer Calls 300 calls @ 3min average 600 minutes of calls Incoming PSTN Office Calls 100 calls @ 3.5min average 240 minutes of calls Outgoing PSTN Calls 200 calls @ 2.5min average 480 minutes of calls Inter-Office Calls 10E a) Dimension the minimum number of exchange lines from the Carrier Exchanges that need to be connected to the Perth and Sydney PABXs to carry the measured Incoming & Outgoing traffic for a Grade of Service of 0.5%. b) Dimension the minimum number of voice tie lines between Perth and Sydney required to carry the measured inter-PABX traffic for a Grade of Service of 0.5%, 1% and 10%. c) Draw a diagram of the above company network showing the number of exchange lines and inter-office tie lines connecting to the Perth and Sydney offices as dimensioned in parts (a) & (b) above? d) Assuming that all customer calls to the Perth & Sydney offices are routed by the Telephone Carrier’s network to the Perth office, re-dimension the PSTN exchange lines and voice tie lines so that the Sydney incoming customer call traffic can be answered in Sydney via the inter-office voice tie lines (Note: Sydney Incoming PSTN Office Calls & Outgoing PSTN calls continue to be connected via Sydney PSTN lines)? In this configuration what Grade of Service have you selected for the PSTN and voice tie line routes and explain why you have selected this GoS. 25% THE 6.7 GHz BAND (6425 – 7110 MHz) RF CHANNEL ARRANGEMENTS fo
ASSIGNMENT INSTRUCTIONS This band is designated for use by digital high capacity fixed point-to-point links. Typical Use : 40 MHz channels – 140 Mbit/s data : 80 MHz channels – 298 Mbit/s data Assignment Priority : 80 MHz channels – from highest channel downwards Minimum Path Length : 20 km Antenna Requirements : refer to Appendix 11 Note: 1. Proposed links need to be coordinated with licensed earth stations operating in this band. 2. The channel raster known previously as the interleaved raster has been removed. No new assignments are to be made. 3. Potential for interference to and from adjacent 6 GHz band fixed services. Reference 1. Rec. ITU-R F.384-5, “Radio-frequency channel arrangements for medium and high capacity analogue or high capacity digital radio-relay systems operating in the upper 6 GHz band”. [6.7 GHz – Page 1 of 3] FX 3 Appendix 1 – RF Channel Arrangements and Assignment Instructions October 2014 THE 6.7 GHz BAND (6425 – 7110 MHz) PROTECTION RATIOS 1. Protection ratios required between digital systems. Frequency Offset (MHz) PROTECTION RATIO (dB) Interferer Tx o Victim Rx 40 MHz p 40 MHz 40 MHz p 80 MHz 80 MHz p 40 MHz 80 MHz p 80 MHz 0 60 69 20 68 56 40 30 60 50 35 80 0 46 100 15 12 140 8 4 160 15 2. Protection ratios required between digital systems in the adjacent 6 GHz band. Frequency Offset (MHz) PROTECTION RATIO (dB) Digital Interferer Tx o Digital Victim Rx 40 MHz p 29.65 MHz 40 MHz p 59.3 MHz 80 MHz p 29.65 MHz 80 MHz p 59.3 MHz 55.21 12 70.035 20 75.21 15 84.86 1.5 90.035 24 104.86 10 Note: 1. Protection ratios for digital systems are based on a 50 km path length and PL (Percentage of time that the average refractivity gradient in the lowest 100 m of the atmosphere is less than or equal to -100 N units/km) of 20. For other path lengths and PL values refer to the protection ratio correction factors graph on the following page. [6.7 GHz – Page 2 of 3] FX 3 Appendix 1 – RF Channel Arrangements and Assignment Instructions October 2014
Source: © AcademicWritersBay.com
>> CLICK HERE TO ORDER 100% ORIGINAL PAPERS FROM AcademicWritersBay.com <<<</strong>
The post Telecommunications & Network Management COMT6001 appeared first on Academic Writers BAy.
0 notes