What is a range - a structured type in ruby, Data Structure & Algorithms

Assignment Help:

Range: A Structured Type in Ruby

Ruby has a numerous structured types, comprising arrays, hashes, sets, classes, streams, and ranges. In this section we would only discuss ranges briefly as an instance of a structured type.

Range of T ADT signifies a set of values of type T (called the base type) between two extremes. Start value is a value of type T which sets the lower bound of a range, and end value is a value of type T which sets the upper bound of a range. Range itself is the set of values of type T between lower and upper bounds. For illustration, Range of Integers from 1 to 10 inclusive is the set of values {1, 2, 3, ..., 10}.

A range can be inclusive, meaning that it includes end value, or exclusive, meaning that it doesn't include the end value. Inclusive ranges are written with two dots between extremes, and exclusive ranges with three dots. Hence Range of Integers from 1 to 10 inclusive is written 1...10, and Range of Integers from 1 to 10 exclusive (the set {1, 2, 3, ..., 9}), is written 1...10.

A type can be a range base type only if it supports order comparisons. For instance, Integer, Real, and String types support order comparisons and so may be range base types however Sets and Arrays don't, so they can't be range base types.

 


Related Discussions:- What is a range - a structured type in ruby

Deletion from a red-black tree, Deletion in a RBT uses two main processes, ...

Deletion in a RBT uses two main processes, namely, Procedure 1: This is utilized to delete an element in a given Red-Black Tree. It involves the method of deletion utilized in

Write an algorithm for binary search, Q.1 Write procedures/ Algorithm to in...

Q.1 Write procedures/ Algorithm to insert and delete an element in to array. Q.2. Write an algorithm for binary search. What are the conditions under which sequential search of

Explain graph traversal, Graph Traversal In many problems we wish to in...

Graph Traversal In many problems we wish to investigate all the vertices in a graph in some systematic order. In graph we often do not have any single vertex singled out as spe

Trees, What is AVL Tree? Describe the method of Deletion of a node from and...

What is AVL Tree? Describe the method of Deletion of a node from and AVL Tree ?

What is string, What is String Carrier set of the String ADT is the s...

What is String Carrier set of the String ADT is the set of all finite sequences of characters from some alphabet, including empty sequence (the empty string). Operations on s

Define a b-tree, Define a B-Tree Justas AVL trees are balanced binary s...

Define a B-Tree Justas AVL trees are balanced binary search trees, B-trees are balanced M-way search trees. A B-Tree of order M is either the empty tree or it is an M-way searc

What are the things require to implement abstract data types, What are the ...

What are the things require to implement ADT Abstract data types are very useful for helping us understand the mathematical objects which we use in our computations but, of cou

Name the five popular hashing functions, Five popular hashing functions are...

Five popular hashing functions are as follows: 1) Division Method 2) Midsquare Method 3) Folding Method 4) Multiplicative method 5) Digit Analysis

Determine the components of illumination, Determine the Components of Illum...

Determine the Components of Illumination The light reaching the eye when looking at a surface has clearly come from a source (or sources) of illumination and bounced off the su

The complexity of searching an element, The complexity of searching an elem...

The complexity of searching an element from a set of n elements using Binary search algorithm is   O(log n)

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd