=> An algorithms are the step by step process of solving any complex problem, For a single problem we can have many solutions or we can say many algorithms. So here question is that how we can define which one is the best algorithms. There are two important things which we follow while algorithms analysis.
1)- Space used
2)- Running Time.
Any algorithms which solve the problem using less space and less time, so that algorithms will be the best algorithms.
Please see below code-
int sum(int arr[], int sizeOfArray){
int temp =0;
for(int i=0;i < sizeOfArray; i++){
temp = temp+arr[i];
}
return temp;
}
Here in above code initialization of "temp" and return statement will take the equal time for all the input, so it is constant for all but the code inside the loop statement is directly depends on the problem size.
So for analysis of any algorithms, we have three cases
1)-Best Case
Let's consider a balanced binary tree, all the elements are equally distributed like below
Here search time complexity is always O(log n)
2)-Worst Case
If the tree is left or right skewed then we need to iterate all the list so worst case will be O(n).
3)Average case
In the average case, it will be O(log n).
Why Measure of Algorithms is Important?
It's very important to measure of algorithms because we can solve a problem many ways but we always select the best way.
Let suppose we have one sorted array and our task is to find the availability of an element into the array. So we can find it two ways
1)- Leaner Way
int search(int arr[], int n, int x)
{
for (int i = 0; i < n; i++)
if (arr[i] == x)
return i;
return -1;
}
The running time complexity of above code is always O(n), because we have to iterate whole list.
2)- Binary Search
int binarySearch(int arr[], int l, int r, int x)
{
if (r >= l)
{
int mid = l + (r - l)/2;
if (arr[mid] == x)
return mid;
if (arr[mid] > x)
return binarySearch(arr, l, mid-1, x);
return binarySearch(arr, mid+1, r, x);
}
return -1;
}
The running time complexity for above code will be O(log n) which is very minimum.
So in the above code, we are given solution for the same problem but the second one is more efficient than first. Measurement of an algorithm is very important.
Question Q/ What have you learned about being able measuring an algorithm and why it is...
Throughout this course you have learned about the importance of being conscientious of others cultures and the environment when advocating for diverse health issues. Think about how you would tackle health issues from the opposite angle, the preventative side. How would you advocate for primary prevention and utilizing effective health promotion strategies? In your initial post, state what you believe to be an effective health promotion strategy and why.
Summarize what you have learned about the last process of the strategic plan from this weeks readings and discussions. Make sure to discuss why measurable goals are important
What did you learn about the legislative process? Explain anything new you learned about how a bill becomes a law and why it is important to health care.
Considering what you have learned about the presocratics and your understanding of science, in what respect do you think the presocratics contributed to science? What are some important differences and similarities between the concepts of modern science and those of the presocratics?
What Is The Most Interesting Topic That You Learned In This Course? Why? What insights have you gained as a result of this course? How does the information you've learned apply to your future goals of being a business owner (home care agency)? Did you accomplish your goals in this course? Yes did accomplish my goals in this course the subject is BUS 625 – Acquisitions in New Business Formation
Being able to read about the different type of approaches that can be used to sequence data through the time-series forecasting it is important to be able to have more than one way to forecast data. Being able to have a simple way to forecast like the Naïve approach is very important because you want to be able to have a way for individual to easily figure out these approaches with using little amounts of time but being able to...
What is something that you have learned that you did not know before? What are the most important concepts,points,and topics you learned that you can take with you into your field/career? What are your thoughts about how you can apply all the information gained?
you have learned about linked lists and about the Java Collection Interface. What is a linked list? Why might we use them? What is the purpose of the Java Collection Interface? Your initial post should be at least 200 to 300 words.
The course is BUSINESS LAW( BUS5 ).Please select a legal principle that you have learned about in this course that you think is important for students to understand. In responding to this discussion board, please address the following questions: Identify the legal principle or rule. Please state the chapter where it was covered. Discuss a case in the textbook which helps to illustrate how this rule was applied. You may also reference a current newspaper article which demonstrates how the...
Think about what you've learned about innovation. What are at least three things that you have learned that you feel have changed the way you see technology and how it impacts the business environment. Be specific.