Purchase Solution

Span of an element in a non-decreasing sorted sequence

Not what you're looking for?

Ask Custom Question

Give the pseudo code for finding the span of an element in a non-decreasing sorted sequence of given length. Sequence is indexed from 1 onwards.

For example, in the sequence {0,2,3,3,4,5,5,5,5,6,8,10,11,11,12}, span of element 5 is [6-9], and for element 2 it is [2,2].

Purchase this Solution

Solution Summary

Solution gives the pseudocode for a simple algorithm to find the span of a given element in the given non-decreasing sorted sequence.

Solution Preview

In the following pseudocode, let S[1..N] indicate the sequence of size N, and e the element whose span we want to find in this sequence.

spanStart = 0
spanEnd = 0
index = 0

While (index < ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

C# variables and classes

This quiz contains questions about C# classes and variables.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.