C Program for Round Robin Scheduling

Sunidhi Bansal
Updated on 23-Dec-2019 07:41:30

9K+ Views

We are given with the n processes with their corresponding burst time and time quantum and the task is to find the average waiting time and average turnaround time and display the result.What is Round Robin Scheduling?Round robin is a CPU scheduling algorithm that is designed especially for time sharing systems. It is more like a FCFS scheduling algorithm with one change that in Round Robin processes are bounded with a quantum time size. A small unit of time is known as Time Quantum or Time Slice. Time quantum can range from 10 to 100 milliseconds. CPU treat ready queue ... Read More

Convert Kilometers to Miles in Python

Pavitra
Updated on 23-Dec-2019 07:37:08

369 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given distance in kilometers and we need to convert it into milesAs we know that 1 kilometer equals 0.62137 miles.Formula UsedMiles = kilometer * 0.62137Now let’s observe the concept in the implementation below−Example Live Demokilometers = 5.5 # conversion factor as 1 km = 0.621371 miles conv = 0.621371 # calculation miles = kilometers * conv print(kilometers, "kilometers is equal to ", miles, "miles")Output5.5 kilometers is equal to 3.4175405 milesAll the variables are declared in the local scope and their references are seen ... Read More

Convert Hex String to Decimal in Python

Pavitra
Updated on 23-Dec-2019 07:35:02

544 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a hexadecimal string, we need to convert it into its decimal equivalent.We have two approaches to solve the problem−Brute-force ApproachUsing Built-in moduleBrute-Force MethodHere we take the help of explicit type casting function i.e. integer. This function takes two arguments i.e. hex equivalent and base i.e. (16). This function is used to convert a hexadecimal string to its equivalent decimal in an integer type, which can be further typecasted back to string format.Example Live Demo#input string string = 'F' # converting hexadecimal string ... Read More

Product of Lengths of All Cycles in an Undirected Graph in C++

Sunidhi Bansal
Updated on 23-Dec-2019 07:30:16

236 Views

We are given with the undirected as well as unweighted graph as an input and the task is to find the product of the cycles that are formed in the given and display the result.ExampleInputIn the given figure, there are 8 nodes and out of that 5 nodes are forming cycle including 1, 6, 3, 5, 8 and rest of the node are not included in the cycle. So, the length of the cycle is 5 as it includes 5 node therefore product is 5In the given figure, there are 12 nodes and out of that 11(5 +6) nodes are ... Read More

Convert a List to String in Python

Pavitra
Updated on 23-Dec-2019 07:28:22

246 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a list iterable, we need to convert it into a string type iterable.There are four approaches to solve the given problem. Let’s see them one by one−Brute-force ApproachExample Live Demodef listToString(s):    # initialize an empty string    str_ = ""    # traverse in the string    for ele in s:       str_ += ele    # return string    return str_ # main s = ['Tutorials', 'Point'] print(listToString(s))OutputTutorialsPointUsing Built-In join() methodExampledef listToString(s):    # initialize an empty string ... Read More

Introduction to Priority Queue in C/C++

Sunidhi Bansal
Updated on 23-Dec-2019 07:25:27

547 Views

A priority queue is a type of queue in which elements are inserted or deleted according to the priorities assigned to them where priority is an integer value that can range between 0-10 where 0 shows the element with the highest priority and 10 shows the element with the lowest priority. There are two rules that are followed for implementing priority queue −Data or element with the highest priority will get executed before the data or element with the lowest priority.If two elements have the same priority than they will be executed in the sequence they are added in the ... Read More

Probability of Getting a Sum on Throwing 2 Dices N Times in C++

Sunidhi Bansal
Updated on 23-Dec-2019 07:24:49

358 Views

We are given with the sum and the number of times the pair of dice is thrown as an input and the task is to determine the probability of getting the given sum on throwing a pair of dice N times.Probability is the chances of getting the desired output from the set of data available. The range of probability lie between 0 and 1 where an integer 0 shows the chances of impossibility and 1 indicates certainty.ExampleInput-: sum = 12, N = 1 Output-: Probability = 1/36 Explanation-: if a pair of dice is thrown once then the combinations will ... Read More

Check If a Given String Is Vowel Palindrome in Python

Pavitra
Updated on 23-Dec-2019 07:17:47

479 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given string (containing both vowel and consonant letters), remove all consonants, then check if the resulting string is a palindrome or not.Here we first remove all the consonants present in the string. A loop to calculate the divisors by computed by dividing each value from 1 to the minimum computedEach time the condition is evaluated to be true counter is incremented by one.Remove all the consonants in the string. Now we check whether the vowel string is a palindrome or not i.e. ... Read More

Priority Queue Using Linked List in C

Sunidhi Bansal
Updated on 23-Dec-2019 07:15:27

4K+ Views

We are given with the data and the priority as an integer value and the task is to create a linked list as per the priority given and display the result.Queue is a FIFO data structure in which the element which is inserted first is the first one to get removed. A Priority Queue is a type of queue in which elements can be inserted or deleted depending upon the priority. It can be implemented using queue, stack or linked list data structure. Priority queue is implemented by following these rules −Data or element with the highest priority will get ... Read More

Check if a Given String is a Keyword in Python

Pavitra
Updated on 23-Dec-2019 07:13:45

511 Views

In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a number, we need to check that the number is a power of two or not.Keywords are the special words reserved by any language with specific usage and cannot be used as an identifier.To check whether the given string is a keyword we used the keyword module as discussed below.Example Live Demo# keyword module import keyword # Function def isKeyword(word) :    # list of all keywords    keyword_list = keyword.kwlist    # check the presence    if word in keyword_list : ... Read More

Advertisements