Implementing the banker algorithm

Assignment Help Data Structure & Algorithms
Reference no: EM1380212

Implement the Banker's algorithm described in Section 8.5.3 using C/C++. Your program should ...

1) Prompt user to enter the size of matrix n and m. Your program should accept any n x m matrix and m vectors where n and m are positive integer less than 10.
2) Read in Allocation, Max, and Available from allocation.txt, max.txt, and available.txt, respectively. You can assume that each entry of the matrix (or vector) in the input files is separated with ' ' or 'n'. That is, the input files

7 5 3 3 2 2 9 0 2 2 2 2

and

7 5 3
3 2 2
9 0 2
2 2 2

are considered to be identical entries, and they can be interpreted as 1x12, 2x6, 3x4, 4x3, and etc depending on the user input n and m. Obviously, your program needs to handle the error when the total number of entries in matrix exceeding the total number of entries in input files.

3) Properly perform Safety algorithm to report user if the initial state is in safe state. If state is safe, report a safe sequence and go to step 4. If not, terminate the program.

4) Prompt user for new Requesti, perform Resource-Request algorithm, and perform Safety algorithm to report if the current state is safe. If state is safe, report a safe sequence. If state is unsafe, output "unsafe"

5) Repeat step 4 above until user terminates the program.

Reference no: EM1380212

Questions Cloud

What the influence on the market supply of labor : Use a graphical illustration to describe briefly what the influence of each of the following would be on the market supply of labor an increase in immigration
Difference between sequential, random and binary file access : Discuss the difference between sequential file access, random file access, and binary file access? For each of the three types, provide an example of an application where the use of one type is better than the other 2-types.
Report writing mechanism : Write a report. You can choose any scientific or informative report to write about
Creating a method find ranks in java : Create a method findRanks in Java that accepts an unsorted array of integers vals, and starting and ending rank start and end, numbering ranks from 0,
Implementing the banker algorithm : Prompt user to enter the size of matrix n and m. Your program should accept any n x m matrix and m vectors where n and m are positive integer less than ten.
Creating a big inteter calculator program : Create a big-inteter calculator program that permits the user to enter two large integers and the operation to be performed and that calls appropriate function to carry out the designated operation.
Question about multi dimensional arrays : Multi-dimensional arrays could cost a lot of memory. Determine how much memory does it take to create an integer array of 3 dimensions,
Income tax project : osalyn uses the Cash Method Of Accounting for Federal Income Tax purposes for her business, ROSALYN'S BOOKSTORE, and the business code for the business for Federal Income Tax purposes
Definition of a method isreverse : Provide the definition of a method, isReverse , whose two parameters are arrays of integers of equal size. The technique returns true if and only if one array is reverse of the other.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Algorithm to take input m constraints over n variables

For instance, the constraints x1 = x2, x2 = x3, x3 = x4, and x1 6= x4 cannot be satis fied. Give an efficient algorithm that takes as input m constraints over n variables and decides whether the constraints can be satis fied.

  Polynomial time algorithm for rooted directed acyclic graphs

Illustrate that if you were given a polynomial time algorithm for determining whether two rooted directed acyclic graphs are isomorphic, then polynomial time algorithm for testing.

  Design time randomized monte carlo algorithm

You have to design an O(n) time randomized Monte Carlo algorithm which computes an (1 + o)- approximate ham-sandwich cut with probability 1 - n-c for any given constant c > 0.

  Creating two single dimension arrays

Make two single dimension arrays that contain ten floating point numbers in each array. Make a third single dimension array to hold a sum.

  Write algorithm to calculate the median using queries

Calculate the median using as few queries as possible. Provide an algorithm which determines the median value using at most O(lg n) queries.

  Use of primitives helps remove ambiguities in algorithm

Explain the distinction between an ambiguity in a proposed algorithm and an ambiguity in the representation of an algorithm. Describe how the use of primitives helps remove ambiguities in an algorithm's representation.

  Design algorithm based on bfs that colors a graph

Design an algorithm based on BFS that either colors a graph with 2 colors or determines that two colors are not sufficient.

  Write the implementation of a data structure

Write an implementation of a data structure S that supports the following operations: Insert(S, x): insert the key x into S only if it is not already there.

  Computing entropy of plaintext message

Compute the entropy of the plaintext message?

  Describe why full binary tree requires to have node

Describe why. Full binary tree requires to have a node with 0 or 2 children and complete tree have their child starting from left. Choose the one true statement. Every binary tree is either complete or full.

  Write algorithm which divides n objects of u into k clusters

Suggest the algorithm which divides n objects of U into k clusters, making use of MST of a graph. Give a simple argument of correctness and bound on the running time of the algorithm you are proposing.

  Creating algorithm to implement function

Create an Algorithm to implement the given function and explain how the required task can be achieved in a step by step process.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd