MY BS-CS-2K11: 
Selection Sort In JavaIntroductionInthis example ...: Selection Sort In Java   Introduction   In this example we are going to sort the values of an array  using selection sort.   In selection...
MY BS-CS-2K11
The only best educational blog for all Universities in Universe
Wednesday, 25 April 2012
Selection Sort In Java
Introduction
In
this example we are going to sort the values of an array  using selection
sort.
In
selection sorting algorithm, find the minimum value in the array then swap it
first position. In next step leave the first value and find the minimum value
within remaining values. Then swap it with the value of minimum index position.
Sort the remaining  values by using same steps. Selection sort  is
probably the most intuitive sorting algorithm to invent.
The complexity of selection sort algorithm is in worst-case, average-case, and best-case run-time of Θ(n2), assuming that comparisons can be done in constant time.
Code description:
The complexity of selection sort algorithm is in worst-case, average-case, and best-case run-time of Θ(n2), assuming that comparisons can be done in constant time.
Code description:
In
selection sort algorithm to find the minimum value in the array. First assign
minimum index in key (index_of_min=x). Then find the minimum value and assign
the index of minimum value in key (index_of_min=y). Then swap the minimum
value with the value of minimum index.
At next iteration leave the value of minimum index position and sort the remaining values by following same steps.
Working of the selection sort :
At next iteration leave the value of minimum index position and sort the remaining values by following same steps.
Working of the selection sort :
Say
we have an array unsorted A[0],A[1],A[2]................ A[n-1] and A[n] as
input. Then the following steps are followed by selection sort algorithm to
sort the values of an array . (Say we have a key index_of_min that indicate the
position of minimum value)
1.Initaily varaible index_of_min=0;
2.Find the minimum value in the unsorted array.
3.Assign the index of the minimum value into index_of_min variable.
4.Swap minimum value to first position.
5.Sort the remaining values of array (excluding the first value).
1.Initaily varaible index_of_min=0;
2.Find the minimum value in the unsorted array.
3.Assign the index of the minimum value into index_of_min variable.
4.Swap minimum value to first position.
5.Sort the remaining values of array (excluding the first value).
class SelectionSorting{
public static void main(String arg[]){
 int a[]={3,30,4,12,1,2,34,22,4,3,5,8};
 System.out.println("\n\nInput values:");
 for(int i=0;i<a.length;i++){
  System.out.print(" "+a[i]);
  }
 for (int i = 0; i < a.length; i++){
     int min = i;
  int j;
  /*
        *  Find the smallest element in the unsorted list
        */
     for (j = i + 1; j < a.length; j++) {
     if (a[j] < a[min]){
   min = j;
   }
   }
   /*
   *  Swap the smallest unsorted element into the end of the sorted list.
   */
   int T = a[min];
   a[min] = a[i];
   a[i] = T;   
        }
 System.out.println("\n\n\nSorted values:");
 for(int i=0;i<a.length;i++)
  {
 System.out.print(" "+a[i]);
     }
}
}
Bubble Sorting in Java
Introduction
In
this example we are going to sort integer values of an array using bubble
sort.
Bubble sort is also known as exchange sort. Bubble sort is a simplest sorting algorithm. In bubble sort algorithm array is traversed from 0 to the length-1 index of the array and compared one element to the next element and swap values in between if the next element is less than the previous element. In other words, bubble sorting algorithm compare two values and put the largest value at largest index. The algorithm follow the same steps repeatedly until the values of array is sorted. In worst-case the complexity of bubble sort is O(n2) and in best-case the complexity of bubble sort is Ω(n).
Bubble sort is also known as exchange sort. Bubble sort is a simplest sorting algorithm. In bubble sort algorithm array is traversed from 0 to the length-1 index of the array and compared one element to the next element and swap values in between if the next element is less than the previous element. In other words, bubble sorting algorithm compare two values and put the largest value at largest index. The algorithm follow the same steps repeatedly until the values of array is sorted. In worst-case the complexity of bubble sort is O(n2) and in best-case the complexity of bubble sort is Ω(n).
Here are code
class BubbleSorting{
public static void main(String arg[]){
 int a[]={2,33,54,12,0,46,34,22,4,4,4,4};
 System.out.println("\n\nInput values:");
 for(int i=0;i<a.length;i++){
  System.out.print(" "+a[i]);
  }
 for (int i = a.length; --i>=0; ){
  for (int j = 0; j<i; j++){
  if (a[j] > a[j+1])
   {
   int T = a[j];
   a[j] = a[j+1];
   a[j+1] = T;
    }
   }   
        }
 System.out.println("\n\n\nSorted values:");
 for(int i=0;i<a.length;i++)
  {
 System.out.print(" "+a[i]);
     }
}
}
Insertion Sort In Java
Introduction
In
this example we are going to sort integer values of an array using
insertion sort.
Insertion sorting algorithm is similar to bubble sort. But insertion sort is more efficient than bubble sort because in insertion sort the elements comparisons are less as compare to bubble sort. In insertion sorting algorithm compare the value until all the prior elements are lesser than compared value is not found. This mean that the all previous values are lesser than compared value. This algorithm is more efficient than the bubble sort .Insertion sort is a good choice for small values and for nearly-sorted values. There are more efficient algorithms such as quick sort, heap sort, or merge sort for large values .
Positive feature of insertion sorting:
1.It is simple to implement
2.It is efficient on (quite) small data values
3.It is efficient on data sets which are already nearly sorted.
The complexity of insertion sorting is O(n) at best case of an already sorted array and O(n2) at worst case .
Insertion sorting algorithm is similar to bubble sort. But insertion sort is more efficient than bubble sort because in insertion sort the elements comparisons are less as compare to bubble sort. In insertion sorting algorithm compare the value until all the prior elements are lesser than compared value is not found. This mean that the all previous values are lesser than compared value. This algorithm is more efficient than the bubble sort .Insertion sort is a good choice for small values and for nearly-sorted values. There are more efficient algorithms such as quick sort, heap sort, or merge sort for large values .
Positive feature of insertion sorting:
1.It is simple to implement
2.It is efficient on (quite) small data values
3.It is efficient on data sets which are already nearly sorted.
The complexity of insertion sorting is O(n) at best case of an already sorted array and O(n2) at worst case .
Here are code
class InsertionSort{
public static void main(String arg[]){
 int a[]={3,30,4,12,1,2,34,22,4,3,5,8};
 System.out.println("\n\nInput values:");
 for(int i=0;i<a.length;i++){
  System.out.print(" "+a[i]);
  }
 for (int i = 1; i < a.length; i++) {
     int j = i;
     int B = a[i];
     while ((j > 0) && (a[j-1] > B)) {
         a[j] = a[j-1];
         j--;
      }
     a[j] = B;           
        }
 System.out.println("\n\n\nSorted values:");
 for(int i=0;i<a.length;i++)
  {
 System.out.print(" "+a[i]);
     }
}
}
School Problems(That`s a student face)
They think Brian’s school problems are my fault. When I said he needed more individual help from the LD teacher, they shook their heads. They only "do collaborative" now. They told me I shouldn’t use the word "dyslexia" because it sounds hopeless. Then they asked how my husband and I were getting along! (Denise, mother of a boy diagnosed with emotional problems, later found to have severe dyslexia.)
The school psychologist said Shannon's learning problems were her fault, that she was lazy and unmotivated and we had to pressure her to work harder. We didn’t allow her to watch television. We didn't allow her to go out with friends. Homework took hours to complete, even when we helped her. She got terribly depressed. We didn’t know what to do. We didn’t want to raise a lazy child. (Emory & Elaine Carter before they learned Shannon had dyslexia and ADHD
The Blame Game
The Blame Game
Parents of special ed kids often say that they are intimidated, patronized and made to feel guilty and inadequate by staff at their children’s school. These parents feel helpless, frustrated, and defensive. 
Not surprisingly, parents behave exactly like other human beings when they are blamed or attacked. Feeling threatened and uncomfortable, most parents try to explain and justify their position, in hopes that they will be understood. A few go on the offense, firing volleys of blame back.
Many parents find these experiences exquisitely painful and humiliating. If they withdraw and try to avoid school functions, they find that they've been labeled as "uninvolved parents." Again, they are blamed for their children’s learning problems.
Not surprisingly, parents behave exactly like other human beings when they are blamed or attacked. Feeling threatened and uncomfortable, most parents try to explain and justify their position, in hopes that they will be understood. A few go on the offense, firing volleys of blame back.
Many parents find these experiences exquisitely painful and humiliating. If they withdraw and try to avoid school functions, they find that they've been labeled as "uninvolved parents." Again, they are blamed for their children’s learning problems.
Sometimes, emotions get out of control. Feelings of anger, bitterness, and betrayal consume parents and school personnel - who are then unable to work together to make educational decisions. In these cases, everyone loses. The child is usually the biggest loser if the parents and educators cannot work together effectively.
What is the basis for these negative experiences? Are parents too sensitive? Do they misperceive and misunderstand what happens in their contacts with educators? Or are parents just over-protective of their children, as many educators claim?
If you are a "special ed" parent, you know that it's hard to fight - and almost impossible to bail out. If your child receives special education services, you have to attend school meetings and you have to cooperate in developing your child’s IEPs. How can you do this?
And here's another question: If the school staff believes that you or your child are responsible for your child’s problems, how can you work with them so your child’s interests are protected? How can you ensure that your child gets a good quality education?
School Culture
School Culture
If you have run into a "brick wall" of resistance when you tried to obtain changes in your child’s educational program, you need to understand how schools really work. You need to learn about "school culture" and the beliefs held by many educators, school psychologists, administrators, and guidance counselors.
Dr. Galen Alessi, Professor of Psychology at Western Michigan University, conducted a fascinating study on school psychologists. Dr. Alessi’s study illustrates why so many parents have problems dealing with schools. Dr. Alessi’s article is "Diagnosis Diagnosed: A Systemic Reaction" published in Professional School Psychology, 3(2), 145-151.
The primary role of the school psychologist is to evaluate children to determine the reasons for learning and behavior problems. According to Dr. Alessi, when a child has trouble learning or behaving in school, the source of the child's problem can usually be traced to one or more of five causes.
First, the child may be misplaced in the curriculum, or the curriculum may include faulty teaching routines.
Second, the teacher may not be implementing effective teaching and/or behavioral management practices.
Third, the principal and/or other school administrators may not be implementing effective school management practices.
Fourth, the parents may not be providing the home-based support necessary for effective learning.
Fifth, the child may have physical and/or psychological problems that contribute to learning problems.
School psychologists from different areas of the country were interviewed and asked to complete an informal survey. The school psychologists were asked if they agreed that the five factors listed above play a "primary role in a given school learning or behavior problem." (Page 148) The school psychologists agreed that these factors, alone or together, played a significant role in children’s learning problems.
The school psychologists were surveyed about the number of children they evaluated during the past year for learning problems. The average number was about 120 cases (or kids). These numbers were rounded to 100 cases for each of the 50 psychologists for a total of 5,000 cases.
Alessi asked these psychologists how many reports they wrote in which they concluded that the child’s learning problem was mainly due to curriculum factors. "The answer was usually none. All cases out of the 5,000 examined confirmed that their schools somehow had been fortunate enough to have adopted only the most effective basal curricula." (Page 148)
Next, he asked how many reports concluded that the referring problem was due primarily to inappropriate teaching practices. "The answer also was none. All cases out of the 5,000 examined proved that their districts had been fortunate enough to have hired only the most skilled, dedicated, and best prepared teachers in the land." (Page 149)
Then, he asked the psychologists how many of their reports found that the problem was due mainly to faulty school administrative factors. "The answer again was none. All cases out of 5,000 examined demonstrated that their districts had hired and retained only the nation’s very best and brightest school administrators." (Page 149)
When asked how many reports concluded that parent and home factors were primarily responsible, the answer ranged from 500 to 1,000 (10% to 20%). These positive findings indicated that we were finally getting close to the source of educational problems in schools. Some children just don't have parents who are smart, competent, or properly motivated to help their children do well in school.
Finally, I asked how many reports concluded that child factors were primarily responsible for the referred problem. The answer was 100%. These 5,000 positive findings uncovered the true weak link in the educational process in these districts: the children themselves.
If only these districts had better functioning children with a few more supportive parents, there would be no educational difficulties. (Page 149)
Dr. Alessi noted that in IEP disputes, "family factors are invoked most often when the parent does not attend the meeting, or if the parent is involved in a way deemed ‘inappropriate’ by the school staff. Otherwise, child factors alone seem to carry the explanatory burden for school learning and behavior problems." (Page 149)
Based on the results of these 5,000 reports prepared by school psychologists, "the results indicate clearly no need to improve curricula, teaching practices, nor school administrative practices and management. The only needs somehow involve improving the stock of children enrolled in the system, and some of their parents." (Page 149)
Alessi expressed serious concerns about his findings. If school psychologists define children’s learning problems as existing solely within the child, "it is equally unclear how school psychologists can help resolve this kind of problem. School psychologists seem to define school problems in ways that cannot be resolved."
When Dr. Alessi shared these findings with the school psychologists, many protested that "all five factors are indeed responsible for school problems in the cases they studied, but that informal school policy (or ‘school culture’) dictates that conclusions be limited to child and family factors.
Many feel that they could lose their jobs were they to invoke school-related factors. Certainly, they claim, their professional lives would be made very uncomfortable . . . The fact remains that no school psychologist in the group had determined that any existing problems were due to school-related factors." (Page 149) 
The "Child-as-the-Problem"
The "Child-as-the-Problem"
Dr. Alessi discussed several additional reasons for the prevailing "child-as-the-problem" perspective of school psychologists. Graduate school programs focus on child problems and ignore or exclude school-related factors. Workshops and papers presented at school psychology conferences share the "child-as-the-problem" focus. Most school psychology journals focus exclusively on child factors.
School psychology textbooks have a clear "child-as-the-problem" bias. After examining several "mainstream" school psychology texts, Alessi found that when assessing children’s reading problems, school factors were mentioned as a factor between 7% and 0% (zero) of the time. "Child factors" were held responsible for reading problems between 90% to 100% of the time.
Citing a classic book on reading disability, Alessi noted that it included no chapters about the connection between reading problems and school factors. The entire book focused on "child factors." (Page 150)
The "child-as-the-problem" bias also pervades school psychology research and practice. Alessi referenced one work that presented an extensive review of the research on learning disabilities. "Of the approximately 1,000 studies reviewed, not one examined the relation between school factors and learning disabilities." (Page 150)
In conclusion, Alessi observed that "Parents trust school psychologists not to adopt assessment practices that are inherently biased in ways that could hinder, rather than help, their children." (Page 148)
"Ethical Burdens" on Psychologists
"Ethical Burdens" on Psychologists
Dr. Alessi discussed the "ethical burdens" on school psychologists:
As this body of research grows, school psychologists will increasingly face the burden of deciding whether they work for the schools or for the children, in cases where the interests clash. (Page 150) 'We end with a discussion of the ethical burdens on school psychologists to be forthright and honest when reporting their findings.'
He posed some questions: (Page 150)
Are we really helping children by concluding that children alone are responsible for their educational problems?Are we helping the school system at the expense of the children?How do we balance the rights of those who pay for our services against those who receive our services, when interests clash?
Is the role of the school psychologist to label children to help schools avoid improving faulty educational practices, or to help schools improve faulty educational practices to avoid labeling children?
Implications
As the parents of a child with special educational needs, what does this study tell you?
If you believe the staff at your child’s school are not willing to look at what they need to do differently to help your child learn, you may be right.
If you believe the staff at your child’s school are not willing to look at what they need to do differently to help your child learn, you may be right.
If you believe that you and/or your child are being blamed for your child’s learning problems, you may be right. 
And if you believe that school factors (i.e., an inappropriate curriculum, faulty teaching, ineffective school administration and management practices) are contributing to your child’s problems, you may be right. 
Now what?
What are the implications of this study for you, the parent of a special needs child? Your job is to work with the school system to secure educational services for your child.
To make good decisions about your child's educational program, you need accurate information about your child's educational difficulties and educational needs. You will find this information in psychological and educational evaluations of your child. If you cannot rely on evaluations by school district personnel for this information, what can you do? Should you ask the school for an "independent educational evaluation?"
You have learned that many people who work in schools share the belief that the problems they have teaching children have little or nothing to do with the curriculum, their own training and experience, or school administrative factors. Instead, they believe that the child’s problems are caused by the child himself. 
Many people who work in schools -- school psychologists, guidance counselors, principals, and special education directors -- share this belief. Because school staff associate with other school staff, they continually reinforce the view of the "child-as-the-problem" in their dealings with one another.
As a parent, can you force educators and school psychologists to change their beliefs? No. This view of the "child-as-the-problem" exists and persists because it serves a purpose.
What would you think if the next time you attended an IEP meeting, the school staff told you that your child’s worsening problems were caused by an inappropriate curriculum? Inadequately trained teachers? An incompetent principal? This won't happen.
As the parent of a special ed child, your job is to negotiate with school staff and secure a good quality special education program for your child. In your role as a negotiator, what do you need to know?
As a negotiator, your single most important tool is to understand and be able to explain the position of the "other side" as well or better than your own!
Once you understand the beliefs and perceptions of the school staff, you will be in a stronger position. You are more likely to accomplish your objective. When you understand how school people think and what they believe, you'll be able to generate "win-win solutions" that meet your child's needs -- and theirs.
Solutions
To accomplish your objective of getting a good educational program for your child, you must have accurate information about your child. This information includes the results of different psychological and educational tests. If you don't have good quality private sector diagnostic evaluations, you wont' be able to develop an appropriate educational program for your child. Knowing that school psychologists are often biased, what options do you have?
Here are Solution of first Chapter of Discrete Math 6th Edition
(For You SAhoo MAtlabi) here are link
http://www.mediafire.com/?w45mefozvflrfon
(For You SAhoo MAtlabi) here are link
http://www.mediafire.com/?w45mefozvflrfon
Subscribe to:
Comments (Atom)
