Bubble sort is an algorithm that compares adjacent elements in an array and swaps them if they are out of order, causing smaller values to "bubble" to the top. It repeats this process, making one pass through the array each time, for a total of N-1 passes where N is the number of elements, to fully sort the array. It uses a flag to detect if any swaps occurred to potentially stop early if the array is already sorted. While simple to implement, bubble sort has poor performance in general cases requiring up to N^2 comparisons and exchanges in the worst case.
The Decision Control Structure - C Programming. C has three major decision making instructions—the if statement, the if-else statement, and the switch statement.
The Decision Control Structure - C Programming. C has three major decision making instructions—the if statement, the if-else statement, and the switch statement.
Splay trees balance trees in a different way from AVL trees. A.docxmckellarhastings
Splay trees balance trees in a different way from AVL trees. An AVL tree always has height
O(log n) meaning that every operation will require O(log n) time which is as good as you can possibly
expect fro a BST. Splay trees allow some operations to take much longer, but the slow operations are
balanced out by a sufficient number of faster ones. This is referred to as amortized complexity where
over a total of n operations on a splay tree the average amount of time spent on each operation is O(log
n). You will see an example of this later.
Pretty much everything you need to know about splay trees is here. You only need to read the first 3
sections. Some important points you will read are: (1) It is possible to have a splay tree with height
O(n) but on average the height will be O(log n). (2) Splay trees require no extra storage so they are
space efficient. AVL trees require a balance factor in each node, so this less true for AVL trees. (3)
Somewhat surprisingly, an element after insertion is moved (splayed) to the root of the tree. His may
sound inefficient but it is during this splaying process that the tree is balanced. (4) The main operations
performed while balancing a splay tree are zig-zig and zig-zag. It’s also possible for there to be a single
zig when the element moves to the root of the tree.
Looking at section 3 on operations, the simple zig step should look familiar to you. It is a simple right
or left rotation. So, looking at the zig step diagram you can see that moving x to the root is just a right
rotation.
When splaying up from further down the tree we always go two steps at once. If the node being splayed
up is either left–left or right–right of its grandparent then a zig-zig splay is performed. Looking at the
zig-zig diagram you can see to accomplish this you must first rotate g to the right, then rotate p to the
right, bringing x two levels higher in the tree. If you do it in the other order you will not end up with
the same tree. I suggest you try it to confirm what I say.
If when splaying up a node it is either left–right or right–left of the grandparent then a zig-zag is
performed. Looking at the zig-zag diagram we this this is done by rotating p left, then g right. Even
though both of these were two separate single rotations, to help remember the algorithm I suggest you
think of them both as different but easy to remember double rotations – just as you should have done
with AVL trees.
Here is an example with some explanations.
Start with an empty tree.
Now insert 10. This is a 1-node tree, 10 is already at the root so no splaying necessary.
10
Insert 20. First insert as you would with any BST, giving
10
20
Now splay 20 to the root. It is just one step away, so a zig brings it to the root.
https://en.wikipedia.org/wiki/Splay_tree
20
10
Now insert 30.
20
10 30
Again, it is one step from the root, so zig it up.
30
20
10
Now insert 4.
Splay trees balance trees in a different way from AVL trees. A.docxmckellarhastings
Splay trees balance trees in a different way from AVL trees. An AVL tree always has height
O(log n) meaning that every operation will require O(log n) time which is as good as you can possibly
expect fro a BST. Splay trees allow some operations to take much longer, but the slow operations are
balanced out by a sufficient number of faster ones. This is referred to as amortized complexity where
over a total of n operations on a splay tree the average amount of time spent on each operation is O(log
n). You will see an example of this later.
Pretty much everything you need to know about splay trees is here. You only need to read the first 3
sections. Some important points you will read are: (1) It is possible to have a splay tree with height
O(n) but on average the height will be O(log n). (2) Splay trees require no extra storage so they are
space efficient. AVL trees require a balance factor in each node, so this less true for AVL trees. (3)
Somewhat surprisingly, an element after insertion is moved (splayed) to the root of the tree. His may
sound inefficient but it is during this splaying process that the tree is balanced. (4) The main operations
performed while balancing a splay tree are zig-zig and zig-zag. It’s also possible for there to be a single
zig when the element moves to the root of the tree.
Looking at section 3 on operations, the simple zig step should look familiar to you. It is a simple right
or left rotation. So, looking at the zig step diagram you can see that moving x to the root is just a right
rotation.
When splaying up from further down the tree we always go two steps at once. If the node being splayed
up is either left–left or right–right of its grandparent then a zig-zig splay is performed. Looking at the
zig-zig diagram you can see to accomplish this you must first rotate g to the right, then rotate p to the
right, bringing x two levels higher in the tree. If you do it in the other order you will not end up with
the same tree. I suggest you try it to confirm what I say.
If when splaying up a node it is either left–right or right–left of the grandparent then a zig-zag is
performed. Looking at the zig-zag diagram we this this is done by rotating p left, then g right. Even
though both of these were two separate single rotations, to help remember the algorithm I suggest you
think of them both as different but easy to remember double rotations – just as you should have done
with AVL trees.
Here is an example with some explanations.
Start with an empty tree.
Now insert 10. This is a 1-node tree, 10 is already at the root so no splaying necessary.
10
Insert 20. First insert as you would with any BST, giving
10
20
Now splay 20 to the root. It is just one step away, so a zig brings it to the root.
https://en.wikipedia.org/wiki/Splay_tree
20
10
Now insert 30.
20
10 30
Again, it is one step from the root, so zig it up.
30
20
10
Now insert 4.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
1.4 modern child centered education - mahatma gandhi-2.pptx
8 elementary sorts-bubble
1. Bubble Sort
Compares adjacent array elements
– Exchanges their values if they are out of order
Smaller values bubble up to the top of the array
– Larger values sink to the bottom
7. Bubble Sort (cont.)
Example:
77123542 5 101
Largest value correctly placed
0 1 2 3 4 5
8. Bubble Sort (cont.)
• Notice that only the largest value is correctly
placed
• All other values are still out of order
• So we need to repeat this process
77123542 5 101
Largest value correctly placed
0 1 2 3 4 5
9. Bubble Sort (cont.)
Repeat “Bubble Up” How Many Times?
If we have N elements…
And if each time we bubble an element, we place it in its correct location…
Then we repeat the “bubble up” process N – 1 times.
This guarantees we’ll correctly place all N elements.
11. Bubble Sort (cont.)
What if the array was already sorted?
What if only a few elements were out of place and after a couple of “bubble ups,”
the array was sorted?
We want to be able to detect this and “stop early”!
12. Bubble Sort (cont.)
Using a Boolean “Flag”
We can use a boolean variable to determine if any swapping occurred during the
“bubble up.”
If no swapping occurred, then we know that the collection is already sorted!
This boolean “flag” needs to be reset after each “bubble up.”
13. public static void BubbleSort( int [ ] num )
{
int j;
boolean flag = true; // set flag to true to begin first pass
int temp; //holding variable
while ( flag )
{
flag= false; //set flag to false awaiting a possible swap
for( j=0; j > num.length -1; j++ )
if ( num[ j ] > num[j+1] ) // change to > for ascending sort
{
temp = num[ j ]; //swap elements
num[ j ] = num[ j+1 ];
num[ j+1 ] = temp;
flag = true; //shows a swap occurred
}
}
}
}
14. Bubble Sort (cont.)
Excellent performance in some cases
– But very poor performance in others!
Works best when array is nearly sorted to begin with
Worst case number of comparisons: n2
Worst case number of exchanges: n2
Best case occurs when the array is already sorted:
– n comparisons
– 0 exchanges