Trending November 2023 # C++ Dynamic Allocation Of Arrays With Example # Suggested December 2023 # Top 13 Popular

You are reading the article C++ Dynamic Allocation Of Arrays With Example updated in November 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested December 2023 C++ Dynamic Allocation Of Arrays With Example

What is a Dynamic Array?

A dynamic array is quite similar to a regular array, but its size is modifiable during program runtime. DynamArray elements occupy a contiguous block of memory.

Once an array has been created, its size cannot be changed. However, a dynamic array is different. A dynamic array can expand its size even after it has been filled.

During the creation of an array, it is allocated a predetermined amount of memory. This is not the case with a dynamic array as it grows its memory size by a certain factor when there is a need.

In this C++ tutorial, you will learn

Factors impacting performance of Dynamic Arrays

The array’s initial size and its growth factor determine its performance. Note the following points:

If an array has a small size and a small growth factor, it will keep on reallocating memory more often. This will reduce the performance of the array.

If an array has a large size and a large growth factor, it will have a huge chunk of unused memory. Due to this, resize operations may take longer. This will reduce the performance of the array.

The new Keyword

In C++, we can create a dynamic array using the new keyword. The number of items to be allocated is specified within a pair of square brackets. The type name should precede this. The requested number of items will be allocated.


The new keyword takes the following syntax:

pointer_variable = new data_type;

The pointer_variable is the name of the pointer variable.

The data_type must be a valid C++ data type.

The keyword then returns a pointer to the first item. After creating the dynamic array, we can delete it using the delete keyword.

Example 1:

using namespace std; int main() { int x, n; cout << “Enter the number of items:” << “n”; int *arr = new int(n); cout << “Enter ” << n << ” items” << endl; for (x = 0; x < n; x++) { } cout << “You entered: “; for (x = 0; x < n; x++) { cout << arr[x] << ” “; } return 0; }


Here is a screenshot of the code:

Code Explanation:

Include the iostream header file into our program to use its functions.

Include the std namespace in our program in order to use its classes without calling it.

Call the main() function. The program logic should be added within the body of the function.

Declare two integer variables x and n.

Print some text on the console prompting the user to enter the value of variable n.

Read user input from the keyboard and assigning it to variable n.

Declare an array to hold a total of n integers and assigning it to pointer variable *arr.

Print a message prompting the user to enter n number of items.

Use a for loop to create a loop variable x to iterate over the items entered by the user.

Read the elements entered by the user and storing them in the array arr.

End of the body of the for loop.

Print some text on the console.

Use a for loop to create a loop variable x to iterate over the items of the array.

Print out the values contained in the array named arr on the console.

End of the body of the for loop.

The program must return value upon successful completion.

End of the body of the main() function.

NOTE: In the above example, the user is allowed to specify any size for the array during run time. This means the array’s size is determined during runtime.

Initializing dynamically allocated arrays

It’s easy to initialize a dynamic array to 0.


int *array{ new int[length]{} };

In the above syntax, the length denotes the number of elements to be added to the array. Since we need to initialize the array to 0, this should be left empty.

Example 2:

using namespace std;

int main(void) {

int x;

int *array{ new int[5]{ 10, 7, 15, 3, 11 } };

cout << “Array elements: ” << endl;

for (x = 0; x < 5; x++) {

cout << array[x] << endl; }

return 0; }


Here is a screenshot of the code:

Code Explanation:

Include the iostream header file into our program to use its functions.

Include the std namespace in our program to use its classes without calling it.

Call the main() function. The program logic should be added within the body of the function.

Declare an integer variable named x.

Declare a dynamic array named array using an initializer list. The array will hold 5 integer elements. Note that we’ve not used the “=” operator between the array length and the initializer list.

Print some text on the console. The endl is a C++ keyword that means end line. It moves the cursor to the next sentence.

Use a for loop to iterate over the array elements.

Print the contents of the array named array on the console.

End of the body of the for loop.

The program must return value upon successful completion.

End of the body of the main() function.

Resizing Arrays

The length of a dynamic array is set during the allocation time.

However, C++ doesn’t have a built-in mechanism of resizing an array once it has been allocated.

You can, however, overcome this challenge by allocating a new array dynamically, copying over the elements, then erasing the old array.

Note: that this technique is prone to errors, hence, try to avoid it.

Dynamically Deleting Arrays

A dynamic array should be deleted from the computer memory once its purpose is fulfilled. The delete statement can help you accomplish this. The released memory space can then be used to hold another set of data. However, even if you do not delete the dynamic array from the computer memory, it will be deleted automatically once the program terminates.


To delete a dynamic array from the computer memory, you should use delete[], instead of delete. The [] instructs the CPU to delete multiple variables rather than one variable. The use of delete instead of delete[] when dealing with a dynamic array may result in problems. Examples of such problems include memory leaks, data corruption, crashes, etc.

Example 3:

using namespace std; int main() { int x, n; cout << “How many numbers will you type?” << “n”; int *arr = new int(n); cout << “Enter ” << n << ” numbers” << endl; for (x = 0; x < n; x++) { } cout << “You typed: “; for (x = 0; x < n; x++) { cout << arr[x] << ” “; } cout << endl; delete [] arr; return 0; }


Here is a screenshot of the code:

Code Explanation:

Include the iostream header file in our program in order to use its functions.

Include the std namespace in our program in order to use its classes without calling it.

Call the main() function. The program logic should be added within the body of the function.

Declare two variables x and n of the integer data type.

Print some text on the console. The text will ask the user to state the number of numbers they will enter.

Read user input from the keyboard. The input value will be assigned to variable n.

Declare a pointer variable *arr. The array arr will reserve some memory to store a total of n integers.

Print a message on the console prompting the user to enter n numbers.

Create a for loop and the loop variable x to iterate over the numbers entered by the user.

Read the numbers entered by the user and storing them in the array arr.

End of the body of the for loop.

Print some text on the console.

Use a for loop and the loop variable x to iterate over the contents of array arr.

Print out the values of the array arr on the console.

End of the body of the for loop.

Print an empty line on the console.

Free up the memory of the array arr.

The program will return value when it completes successfully.

End of the body of the main() function.


Regular arrays have a fixed size. You cannot modify their size once declared.

With these types of arrays, the memory size is determined during compile time.

Dynamic arrays are different. Their sizes can be changed during runtime.

In dynamic arrays, the size is determined during runtime.

Dynamic arrays in C++ are declared using the new keyword.

We use square brackets to specify the number of items to be stored in the dynamic array.

Once done with the array, we can free up the memory using the delete operator.

Use the delete operator with [] to free the memory of all array elements.

A delete without [] frees the memory of only a single element.

There is no built-in mechanism to resize C++ arrays.

To initialize an array using a list initializer, we don’t use the “=” operator.

You're reading C++ Dynamic Allocation Of Arrays With Example

The Importance Of Dynamic Rendering With Geoff Atkinson

Your browser does not support the audio element.

For episode 189 of The Search Engine Journal Show, I had the opportunity to interview Geoff Atkinson, Founder and CEO, Huckabuy.

Atkinson talks about dynamic rendering, how it helps search engines index JavaScript websites faster, and who can benefit from this solution.

What is dynamic rendering?

Geoff Atkinson (GA): Dynamic rendering is probably the biggest change Google’s made in maybe 10 years.

For them to actually offer, “we’ll crawl something that’s different than what the user experience is now, content and data all need to match up,” that’s big change for them.

For years they were like, “you have to have the user experience be the same thing.”

Brent Csutoras (BC): For context, anything that was different previously was considered cloaking. Right?

GA: Correct. So dynamic rendering, it’s actually a pretty straightforward concept. It started with the difference between a mobile device and a desktop.

All it means is that our URL will render differently or dynamically based on what calls it.

So if you call a webpage from your mobile device, you’re going to get one experience.

If you call one from your desktop, you’re going to get a slightly different one.

Their big change was they said, well, now you can actually give a version for us.

And really, the reason for that is around the amount of JavaScript and front end dynamic technologies that have made it difficult for them to crawl and understand a site.

They basically said, “Here’s a way for us to keep it simple. Give us a simplified version and we’ll be able to crawl and index that much more efficiently than what the user’s experiencing.”

What would be an example of what dynamic rendering would actually do?

GA: I’d say the most famous JavaScript thing that really makes Google get caught up while crawling is actually chat boxes, personalization, tracking tags that are dynamic.

As soon as they hit JavaScript, they simply can’t crawl it with their HTML crawler. And so it goes to a rendering queue and a rendering queue takes quite a bit more processing time.

And a rendering queue is literally the same technology as your Chrome browser.

It’s just executing a page fully, allowing them to come in and actually crawl that dynamic content and it takes more processing time, so if you can strip that stuff out in a dynamically rendered version.

What are the other things that dynamic rendering will do for somebody’s website that they might not get otherwise?

GA: [Y]ou could have all the content resources in the world, but if Google can’t see that actual content, what good is it doing? So we see that a lot.

I think companies have bigger indexation issues than they have any idea because it’s kind of hard. You see the crawl stats, right? And you’re like, “Oh, they’re crawling me, I’m good.”

And you see that they’re downloading information but you don’t really know exactly what they’re downloading and how much of it, are they actually accessing the stuff that you’re working on.

All those problems just get eliminated. You get almost instantaneous, all the content is being indexed and content affects rankings and rankings affect traffic.

You get a huge, pretty significant benefit if the site is pretty heavy and JavaScripts are difficult to crawl.

All of a sudden they’re going to become privy to all this new information in a very short amount of time and that’s actually going to impact rankings and traffic and all those other good things.

Why do you think the SEO community as a whole is kind of not really embraced this or that it’s not on every site?

GA: Yeah, I find that shocking. But if we just sort of take a step back and we look at marketing departments and their general skillset, like even SEO groups sometimes aren’t the most technical.

So if you think of a marketing organization, their skill set is really not technical SEO, that’s the last thing that they’re going to get to, right?

They don’t have developers working on SEO, very rarely.

And it’s a very technical problem, so you can throw tons of resources that content and link building and all those sort of more straight forward tasks and not even fully understand or fully recognize the technical problems that you have because you just don’t have that skillset on the team.

And we see that almost happen everywhere. Like even if they’re working with an agency or whoever, that technical skill set is so rare…

Within our little community it’s big, right?

But for when you step into a big internal marketing team, there’s just no one there that speaks that language.

So, I think that’s the reason is that it’s such a different hat to wear as a marketer getting into technical SEO versus managing your PPC spend or your content team or branding and messaging or social.

It’s just a totally different skillset and it’s usually missing, so I think that’s kind of why it hasn’t been adopted as quickly as we would like.

On technical SEO initiatives: how could SEOs connect and convince the developers?

GA: I think about almost every organization, think about just the SEOs you talked to and whether they feel empowered or it’s a bottleneck getting through development and it’s almost always a bottleneck…

It is like an organizational mindset that you have to get in.

Do you feel like everybody needs to have dynamic rendering?

GA: I’d say probably 60% of sites out there need it, which is a lot.

And then there’s 40% where it’s like, it’d be a nice-to-have, but it’s not going to blow your socks off.

Like you’re getting enough, it’s a really small site, maybe there’s only a hundred pages index so Google can get through it. The site doesn’t change that much.

There’s just not as much upside as some of these larger sites that are more complicated that Google is really struggling to understand them.

So there are a good number of sites that don’t necessarily need it.

Everybody could benefit, but what we find is about 60% of the internet, like really could use this solution.

Think about the number of JavaScript things that are included by business owners on their websites without thinking at all about what this does for Google crawling.

And then, of course, they’re going to be like, “Yeah, we want personalization and we want chat boxes,” and so they just throw it on there.

Meanwhile, it makes Google’s job like impossible…

What does it look like to implement dynamic rendering?

GA: So the first piece, how to do it on your own.

The crux of dynamic rendering is really the conversion of your dynamic content into flat HTML. The technical challenge is to be able to do that.

If you have content being generated through JavaScript that is important for your rankings and you want Google to be aware of it, being able to convert that into flat HTML and leveraging some sort of CDN (like Cloudflare, CloudFront or Akamai) to be able to basically load that information up really quickly and eliminate literally all the JavaScript on the page, that’s how you kind of have to go.

It’s doable for sure. We actually see some companies doing it in house, it’s kind of hard to do in house, but we see it happening.

The second piece is automation.

We’ve built that converter… we don’t actually have to have any developer look at your site. They don’t have to log in and do a bunch of work.

You literally make a DNS change and then Huckabuy takes over the bot traffic and we create this dynamic rendered version through SEO Cloud that’s flat HTML.

We have a partnership with CloudFlare that allows us to keep all this information at edge. You kind of hear that term now being used at edge SEO.

So at edge basically means it’s pre-cached and located all around the world in 200 different locations so that no matter where a bot is coming in from, they get this really lightweight and cached page…

This podcast is brought to you by Ahrefs and Opteo.

To listen to this Search Engine Show Podcast with Geoff Atkinson:

Listen to the full episode at the top of this post

Subscribe via Apple Podcasts

Sign up on IFTTT to receive an email whenever the Search Engine Journal Show RSS feed has a new episode

Listen on Stitcher, Overcast, or TuneIn

Visit our podcast archive to listen to other Search Engine Journal Show podcasts!

Image Credits

Featured Image: Paulo Bobita

A Quick Glance Of Matlab Trapz() With Proramming Example

Introduction to Matlab trapz()

MATLAB has incorporated the function trapz to process numerical integration using trapezoidal rule-following unit spacing. This rule is defined to approximate a numerical integration for a definite time frame by dividing the area under the plot into tine sized trapezoids. It helps in forming easily computable areas. The function returns the single return value of type scalar which is the final value of the integration.

Preferably trapz is recommended to use for numerical integration on discrete type data sets.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others


This integrating function trapz accepts different input arguments to decide on the behavior of the integration function, being used with different syntaxes respectively.

They are:

Syntax Description

Q = trapz(Y) This syntax calculates the approximate integral value for ‘Y’ with unit spacing where the dimensions of the integration is determined based on the size of ‘Y’.

Q = trapz(X,Y) This syntax calculates the approximate integral value for ‘Y’ with ‘X’ specified scalar spacing, where the dimensions of the integration is determined based on the size of ‘Y’.

This syntax calculates the approximate integral value for the input with the dimensions of the integration given as ‘dim’.

The input arguments that contribute to different syntaxes of the function trapz can be explained as below:

Numeric Data-Y

The input data over which trapz function is called to operate numerical integration operation.

Depending on the nature of ‘Y’ the integration operation takes place differently such as:

1. Y as vector àThe output is an approximated integral result for ‘Y’

3. Y as multi-dimensional arrayà The operation takes place on the first non-unit sized dimension of ‘Y’ and results in the size of value 1 for that dimension while the size of the other dimensions remains unchanged.

The data type supported by ‘Y’ are:

single/ double/ complex number

Point spacing-X

The specified point spacing value over which the number of trapezoids to be formed is decided.

Value of X of different nature needs to follow come conditions as mentioned below:

1. X as vector à The length of the coordinate vector must be equal to the size of the first non-unit sized dimension of the numerical input ‘Y’.

2. X as scalaràIt satisfies the condition as

trapz(Y, X) = X*trapz(Y)

The default value of ‘X’ is ‘1’.

The data type supported by ‘X’ are single/ double

Dimensions for operation-dim

Decides the direction along which the integration operation will be performed.

2 different dimensions in which trapz works are as follows:

1. trapz(Y,1):

It operates on elements with columns of ‘Y’, returning a row vector as output.

2. trapz(Y,2):

It operates on elements with rows of ‘Y’, returning a column vector as output.

The value is dim must be a positive integer.

Examples of Matlab trapz()

Here are the following examples mention below:

Example #1 – Numerical integration with Unit spacing

This operation can be executed by applying the syntax Q = trapz(Y) in the trapz function implementation in the MATLAB code.


The below code snippet is written to execute trapz operation on input numeric ‘Y’ as f(x)= 10*2^x.

Q = trapz(Y)


Example #2 – Numerical integration with Non-Unit spacing

This operation can be executed by applying the syntax Q = trapz(Y, X) in the trapz function implementation in the MATLAB code.


The below code is written to call trapz function on input numeric data ‘Y’ having point spacing value of pi/10.


Example #3 – Numerical integration with non-uniform spacing

This operation can be executed by applying the syntax Q = trapz(Y, X, dim) in the trapz function implementation in the MATLAB code.


The below code is written to call the trapz function on the input numeric data ‘Y’ with non-uniform point spacing values defined by ‘X’ with the value of ‘dim’ as ‘2’.

The point spacing is obtained by matrix ‘X’ which indicates that the trapezoids are formed non-uniformly.

The rows in input numeric data ‘Y’ is obtained from velocity data taken at 3 different trials.

Q = trapz(X,Y,2)


Trapz is executed on each row of the input numeric ‘Y’ as the value for ‘dim’ is set to 2. The resultant output is a column vector having an integration result for each row.

Example #4 – Multiple numerical integrations

The integration function trapz can also be used to perform double integral i.e integration in the format:

In order to perform trapz function on double integral expression, the function is called in the nested loop as demonstrated in the below example:

I = trapz(q,trapz(p,F,2))


Example #5 – Real-time application of trapz

The trapz in MATLAB plays a vital role in integration calculations applied in real-time applications.


Trapz can be used to compute the average energy exhibited by an electrical machine for which v-i nonlinear relation is designed as:

The instantaneous voltage v(t)= sin(3t).

In the below code snippet the point spacing is defined by ‘time’ which is non-unit uniform spacing with the value of ‘10’.

The instantaneous power is calculated as p = f(i,v) = v*i.

The average energy (enrgy)  is calculated by applying the trapz function.

xlabel(‘in seconds’); ylabel(‘in joules’)


Additional Note

The integration function trapz is similar to cumtrapz and difference lies as it reduces the dimension size to one and returns a single value without returning any intermediate values of integration.

If input numeric data ‘Y’ is multidimensional array by nature, it works across the first non-singleton dimension whereas the size of other dimensions remains unaffected.

It is similar to integral() and differs in the supported input data types. The function trapz works with discrete values whereas integral() works strictly with function (expression) integration operation.

Recommended Articles

This is a guide to Matlab trapz(). Here we discuss the different an introduction to Matlab trapz() with appropriate syntax and examples. You may also have a look at the following articles to learn more –

How To Implementgrid View With Example

Introduction to chúng tôi Grid View

Grid view is one of the very popular views in the current IT industry. This is one of the very common expectations currently by every client for presenting their screen specifically in Grid view. It is basically a table presentation based on the values that came from one data source. It can able to control that specific data source and display in the screen as per the requirement of the client, mainly each column considering as a field in the data source and each row considering as a record of that specific column. This control has various features for multiple types of presentation on the screen, we will cover it in this document in detail.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Syntax of chúng tôi GridView Gridview is one of the very popular implementations for the specific applications in the current scenario. Grid view mainly handles data sources, controlling the same, display it on the screen as a table. Here every column is mainly representing as a field, and each row in the data source represents a specific record of that corresponding column.

There have multiple features supports by this Grid view, explaining below:

SQLDataSource: Mainly require to maintain binding. Passing data source have huge data which mainly relate to specific fields in the screen. This control helps for binding those fields with data source available data.

Sorting: It has the ability to sorting the data. This Grid view presentation default gives one sorting utility, don’t need to write any additional code for that. Representing data can be sort as ascending or descending order based on the link provided in the screen.

Updating & Deleting: Can update or delete any data from the screen or data source. This ability ensures easy handle of the data from the screen by the end-user. This facility can be given based on some chosen parameters of the grid view presentation.

Pagination: This is also very much requiring features of any of the views presented in the current industry. When huge data came into the data source and Grid view unable to present entire data on the screen, it can default break it with multiple pages and giving this pagination utility to the end-user. It also has searching utility with any text, which helps the user to find out specific data easily.

Row selection: This is also one of the key utilities. Grid view gives the option to end-user for selecting one specific row, modify the required data, and save it. Modified data immediately display on the screen in the proper or expected view.

Key Fields: Grid view provided multiple key fields for presenting or handling big data from the data source.

Hyperlink: Grid view give good utility of handling multiple data source specifically on the hyperlink columns. Hyperlink columns have verities fields which developer can utilize as per their requirement.

Themes & Style: Grid view provides the ability of multiple appearances which can be easily handled by themes & style utilities have given by Grid view.

Example to Implement chúng tôi Grid View

Creating a grid view presentation in chúng tôi application, developer normally needs to use below specific code:

Entire GridView presentation can be done by one behind the ASPX code for handling the dashboard and proper presentation.

Binding data in the GridView dashboard presentation with specific columns.

Edit corresponding data in the grid view.

Delete specific rows from the dashboard.

HTML code:

<asp:GridView runat=”server” AutoGenerateColumns=”False” OnRowEditing=”GridView1_RowEditing” OnRowUpdating=”GridView1_RowUpdating” OnRowCancelingEdit=”GridView1_RowCancelingEdit” <asp:RequiredFieldValidator runat=”server” ControlToValidate=”TextBox2″ <asp:RequiredFieldValidator runat=”server” ControlToValidate=”TextBox4″

Adding Page:


public void BindMyGridview() { if (Session["myDatatable"] != null) { DataTable dt = (DataTable)Session["myDatatable"]; { GridView1.Visible = true; GridView1.DataSource = dt; GridView1.DataBind(); } else { GridView1.Visible = false; } } }

Row Updating:

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox TextBoxWithID = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2"); TextBox TextBoxWithName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox4"); string NewID = TextBoxWithID.Text.ToString(); string NewName = TextBoxWithName.Text.ToString(); DataTable dt = (DataTable)Session["myDatatable"]; DataRow dr = dt.Rows[e.RowIndex] dr["ID"] = NewID; dr["Name"] = NewName; dr.AcceptChanges(); Session["myDatatable"] = dt; GridView1.EditIndex = -1; BindMyGridview(); }

Row Deleting:

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { DataTable dt = (DataTable)Session["myDatatable"]; DataRow dr = dt.Rows[e.RowIndex]; dt.Rows.Remove(dr); GridView1.EditIndex = -1; BindMyGridview(); }

Select DOT NET Framework 3.5 from the drop-down.

Open the page design page, where all the attribute needs to be designed.

Take one new form for proper design. Inside the form, the table has been designed. ID and Name are there where specific data table data should display.

Choose a specific online template for writing the background logic of the Grid View presentation.

Preparing the code for the application and mapping the corresponding field for further execution.

Choosing specific data sources for using and presenting Grid view data as per requirement.

Designing the dashboard also been executing in the preview page, displaying require information.

Writing the ASPX code for preparing the view presentation. It automatically came based on the page design.

Working with a text box to define the field name, catch with the value, and perform the required tasks.

Set one specific dashboard page as a starting page for running the application.

Add multiple data for generating a proper grid view presentation.

Add another data for the proper grid view dashboard presentation.

Adding one more data for displaying more in the dashboard.

Displaying the main dashboard of grid view, where all the added data properly displayed on the screen including edit and delete link.

After the update, this page again returns back to the dashboard with a proper grid view.

The delete button is there for deleting one specific record from the grid view presentation.

Conclusion Grid view presentation is one of the common and key requirements from any of the clients in the current scenario. This presentation or designing the page is comparatively easy to do for the developer rather than performing normal design. The page has multiple fields to handle and present. Every field is actually bound with corresponding data coming from the backend code.

Recommended Articles

We hope that this EDUCBA information on “ASP.NET GridView” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

What Is Recovery Testing? With Example

Recovery Testing

Recovery Testing is software testing technique which verifies software’s ability to recover from failures like software/hardware crashes, network failures etc. The purpose of Recovery Testing is to determine whether software operations can be continued after disaster or integrity loss. Recovery testing involves reverting back software to the point where integrity was known and reprocessing transactions to the failure point.

Recovery Testing Example

When an application is receiving data from the network, unplug the connecting cable.

After some time, plug the cable back in and analyze the application’s ability to continue receiving data from the point at which the network connection was broken.

Restart the system while a browser has a definite number of sessions open and check whether the browser is able to recover all of them or not

In Software Engineering, Recoverability Testing is a type of Non- Functional Testing. (Non- functional testing refers to aspects of the software that may not be related to a specific function or user action such as scalability or security.)

The time taken to recover depends upon:

The number of restart points

A volume of the applications

Training and skills of people conducting recovery activities and tools available for recovery.

When there are a number of failures then instead of taking care of all failures, the recovery testing should be done in a structured fashion which means recovery testing should be carried out for one segment and then another.

It is done by professional testers. Before recovery testing, adequate backup data is kept in secure locations. This is done to ensure that the operation can be continued even after a disaster.

Life Cycle of Recovery Process

The life cycle of the recovery process can be classified into the following five steps:

Normal operation

Disaster occurrence

Disruption and failure of the operation

Disaster clearance through the recovery process

Reconstruction of all processes and information to bring the whole system to move to normal operation

Let’s discuss these 5 steps in detail-

A system consisting of hardware, software, and firmware integrated to achieve a common goal is made operational for carrying out a well-defined and stated goal. The system is called to perform the normal operation to carry out the designed job without any disruption within a stipulated period of time.

A disruption may occur due to malfunction of the software, due to various reasons like input initiated malfunction, software crashing due to hardware failure, damaged due to fire, theft, and strike.

If a backup plan and risk mitigation processes are at the right place before encountering disaster and disruption, then recovery can be done without much loss of time, effort and energy. A designated individual, along with his team with the assigned role of each of these persons should be defined to fix the responsibility and help the organization to save from long disruption period.

Reconstruction may involve multiple sessions of operation to rebuild all folders along with configuration files. There should be proper documentation and process of reconstruction for correct recovery.

Restoration Strategy

The recovery team should have their unique strategy for retrieving the important code and data to bring the operation of the agency back to normalcy.

The strategy can be unique to each organization based on the criticality of the systems they are handling.

The possible strategy for critical systems can be visualized as follows:

To have a single backup or more than one

To have multiple back-ups at one place or different places

To have an online backup or offline backup

Can the backup is done automatically based on a policy or to have it manually?

To have an independent restoration team or development team itself can be utilized for the work

Each of these strategies has cost factor associated with it and multiple resources required for multiple back-ups may consume more physical resources or may need an independent team.

Many companies may be affected due to their data and code dependency on the concerned developer agency. For instance, if Amazon AWS goes down its shuts 25 of the internet. Independent Restoration is crucial in such cases.

How to do Recovery Testing

While performing recovery testing following things should be considered.

We must create a test bed as close to actual conditions of deployment as possible. Changes in interfacing, protocol, firmware, hardware, and software should be as close to the actual condition as possible if not the same condition.

Through exhaustive testing may be time-consuming and a costly affair, identical configuration, and complete check should be performed.

If possible, testing should be performed on the hardware we are finally going to restore. This is especially true if we are restoring to a different machine than the one that created the backup.

Some backup systems expect the hard drive to be exactly the same size as the one the backup was taken from.

Online backup systems are not an exception for testing. Most online backup service providers protect us from being directly exposed to media problems by the way they use fault-tolerant storage systems.

While online backup systems are extremely reliable, we must test the restore side of the system to make sure there are no problems with the retrieval functionality, security or encryption.

Testing procedure after restoration

Most large corporations have independent auditors to perform recovery test exercises periodically.

The expense of maintaining and testing a comprehensive disaster recovery plan can be substantial, and it may be prohibitive for smaller businesses.

Smaller risks may rely on their data backups and off-site storage plans to save them in the case of a catastrophe.

After folders and files are restored, following checks can be done to assure that files are recovered properly:

Rename the corrupted document folder

Count the files in the restored folders and match with it with an existing folder.

Open a few of the files and make sure they are accessible. Be sure to open them with the application that normally uses them. And make sure you can browse the data, update the data or whatever you normally do.

It is best to open several files of different types, pictures, mp3s, documents and some large and some small.

Most operating systems have utilities that you can use to compare files and directories.


In this tutorial, we have learned a various aspect of recovery testing that helps to understand whether the system or program meets its requirements after a failure.

Data Types In R With Example

In this tutorial, you will learn:

What are the Data Types in R?

Following are the Data Types or Data Structures in R Programming:


Vectors (numerical, character, logical)


Data frames


Basics types

4.5 is a decimal value called numerics.

4 is a natural value called integers. Integers are also numerics.

TRUE or FALSE is a Boolean value called logical binary operators in R.

The value inside ” ” or ‘ ‘ are text (string). They are called characters.

We can check the type of a variable with the class function

Example 1: # Declare variables of different types # Numeric x <- 28 class(x)


## [1] "numeric" Example 2: # String y <- "R is Fantastic" class(y)


## [1] "character" Example 3: # Boolean z <- TRUE class(z)


## [1] "logical" Variables

Variables are one of the basic data types in R that store values and are an important component in R programming, especially for a data scientist. A variable in R data types can store a number, an object, a statistical result, vector, dataset, a model prediction basically anything R outputs. We can use that variable later simply by calling the name of the variable.

To declare variable data structures in R, we need to assign a variable name. The name should not have space. We can use _ to connect to words.

To add a value to the variable in data types in R programming, use <- or =.

Here is the syntax:

# First way to declare a variable: use the `<-` name_of_variable <- value # Second way to declare a variable: use the `=` name_of_variable = value

In the command line, we can write the following codes to see what happens:

Example 1: # Print variable x x <- 42 x


## [1] 42 Example 2: y <- 10 y


## [1] 10 Example 3: # We call x and y and apply a subtraction x-y


## [1] 32 Vectors

A vector is a one-dimensional array. We can create a vector with all the basic R data types we learnt before. The simplest way to build vector data structures in R, is to use the c command.

Example 1: # Numerical vec_num <- c(1, 10, 49) vec_num


## [1] 1 10 49 Example 2: # Character vec_chr <- c("a", "b", "c") vec_chr


## [1] "a" "b" "c" Example 3: # Boolean vec_bool <- c(TRUE, FALSE, TRUE) vec_bool



We can do arithmetic calculations on vector binary operators in R.

Example 4: # Create the vectors vect_1 <- c(1, 3, 5) vect_2 <- c(2, 4, 6) # Take the sum of A_vector and B_vector sum_vect <- vect_1 + vect_2 # Print out total_vector sum_vect


[1] 3 7 11 Example 5:

In R, it is possible to slice a vector. In some occasion, we are interested in only the first five rows of a vector. We can use the [1:5] command to extract the value 1 to 5.

# Slice the first five rows of the vector slice_vector <- c(1,2,3,4,5,6,7,8,9,10) slice_vector[1:5]


## [1] 1 2 3 4 5 Example 6:

The shortest way to create a range of values is to use the: between two numbers. For instance, from the above example, we can write c(1:10) to create a vector of value from one to ten.

# Faster way to create adjacent values c(1:10)


## [1] 1 2 3 4 5 6 7 8 9 10 R Arithmetic Operators

We will first see the basic arithmetic operators in R data types. Following are the arithmetic and boolean operators in R programming which stand for:

Operator Description

+ Addition

– Subtraction

* Multiplication

/ Division

^ or ** Exponentiation

Example 1: # An addition 3 + 4


## [1] 7

You can easily copy and paste the above R code into Rstudio Console. The output is displayed after the character #. For instance, we write the code print(‘Guru99’) the output will be ##[1] Guru99.

The ## means we print output and the number in the square bracket ([1]) is the number of the display

Example 2: # A multiplication 3*5


## [1] 15 Example 3: # A division (5+5)/2


## [1] 5 Example 4: # Exponentiation 2^5


Example 5: ## [1] 32 # Modulo 28%%6


## [1] 4 R Logical Operators

With logical operators, we want to return values inside the vector based on logical conditions. Following is a detailed list of logical operators of data types in R programming

Logical Operators in R

The logical statements in R are wrapped inside the []. We can add as many conditional statements as we like but we need to include them in a parenthesis. We can follow this structure to create a conditional statement:

variable_name[(conditional_statement)] Example 1: # Create a vector from 1 to 10 logical_vector <- c(1:10)



In the example below, we want to extract the values that only meet the condition ‘is strictly superior to five’. For that, we can wrap the condition inside a square bracket precede by the vector containing the values.

# Print value strictly above 5


## [1] 6 7 8 9 10 Example 3: # Print 5 and 6 logical_vector <- c(1:10)


## [1] 5 6

Update the detailed information about C++ Dynamic Allocation Of Arrays With Example on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!