<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6755409718803839197</id><updated>2024-11-06T08:28:06.899+05:30</updated><category term="C++"/><category term="python"/><category term="Algorithm"/><category term="arrays"/><category term="sorting"/><category term="prefix sum"/><category term="3d"/><category term="searching"/><category term="2d"/><category term="AI Technology"/><category term="Artificial Intelligent"/><category term="GPT-3"/><category term="Machine Learning"/><category term="Recursion"/><category term="Tech"/><category term="competitive programming"/><category term="converter"/><category term="geometry"/><category term="header file"/><category term="number system"/><category term="numpy"/><category term="objects"/><category term="pascal&#39;s triangle"/><category term="pattern"/><category term="quadrilateral"/><category term="string"/><category term="vector"/><title type='text'>AlgorithmTech.Tech | Explore New Technology </title><subtitle type='html'>Problems and its implications in cpp and python&#xa;| unique problem solution | binary to decimal hexadecimal octal | decimal to binary hexadecimal octal | octal to decimal binary hexadecimal | hexadecimal to decimal binary octal </subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>26</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-8322659450822761992</id><published>2023-01-30T14:42:00.010+05:30</published><updated>2023-06-30T21:59:29.127+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AI Technology"/><category scheme="http://www.blogger.com/atom/ns#" term="GPT-3"/><category scheme="http://www.blogger.com/atom/ns#" term="Tech"/><title type='text'>Exploring the Power and Potential of GPT-3: The Next Generation of AI Technology</title><content type='html'>
&lt;div id=&quot;atContainer-6807fa1bbb734829038868d22054e9fe&quot;&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMxsjQZJz6Qf2mYo3h7EdqaJVHv_AP-sr8C7AOLywrfksr-Ibz_S7D5B-jyXjZVhvoOH3VeO8uuOB5PZ2P-_hbIhzEo1c8OSs0kufZNir-LgilWZenTq6XBS5pbXFDQWhPDu9q5wRQ6RDIy1MipsW6OcA4SgmQGrdYwVuH1FYK926vxLpee4N4cGyV/s1024/Exploring%20the%20Power%20and%20Potential%20of%20GPT-3_%20The%20Next%20Generation%20of%20AI%20Technology%20.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;999&quot; data-original-width=&quot;1024&quot; height=&quot;624&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMxsjQZJz6Qf2mYo3h7EdqaJVHv_AP-sr8C7AOLywrfksr-Ibz_S7D5B-jyXjZVhvoOH3VeO8uuOB5PZ2P-_hbIhzEo1c8OSs0kufZNir-LgilWZenTq6XBS5pbXFDQWhPDu9q5wRQ6RDIy1MipsW6OcA4SgmQGrdYwVuH1FYK926vxLpee4N4cGyV/w640-h624/Exploring%20the%20Power%20and%20Potential%20of%20GPT-3_%20The%20Next%20Generation%20of%20AI%20Technology%20.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;Introduction&amp;nbsp;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;GPT-3 (Generative Pretrained Transformer 3) is a state-of-the-art language processing AI technology developed by OpenAI. With its advanced natural language processing capabilities, GPT-3 is able to generate human-like text and perform a wide range of language-related tasks, including translation, question answering, and content creation. GPT-3&#39;s powerful and flexible architecture allows it to be used in a wide range of industries, from customer service to content creation, and its ability to quickly adapt to new tasks and changing data sets makes it a game-changer in the AI industry. With its powerful and ever-growing capabilities, GPT-3 has the potential to revolutionize the way we interact with and use language technology.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Explanation of GPT-3&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 is an advanced AI language model that is designed to generate human-like text and perform a wide range of language-related tasks. It uses a deep neural network and large amounts of training data to create a highly sophisticated model that is capable of understanding and generating text with remarkable accuracy. With its powerful language processing capabilities, GPT-3 is able to respond to natural language questions, translate text between languages, and even write complete articles or essays. The key to GPT-3&#39;s success is its ability to learn patterns and relationships in the data it is trained on, and then apply that knowledge to new and unseen data. This allows it to generate accurate and coherent text that often mimics human writing. With its impressive capabilities, GPT-3 is poised to have a major impact on industries ranging from customer service to content creation.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Importance of GPT-3 in AI and technology&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 represents a significant step forward in the field of AI and language technology. With its advanced natural language processing capabilities and ability to perform a wide range of tasks, GPT-3 has the potential to revolutionize the way we interact with and use language technology. The potential applications for GPT-3 are vast, from customer service and content creation to education and healthcare. By automating many language-related tasks that were previously performed by humans, GPT-3 has the potential to significantly increase efficiency and productivity across a wide range of industries. In addition, GPT-3&#39;s ability to quickly adapt to new data sets and new tasks makes it a highly versatile tool that can be used in a variety of different settings. With its unique combination of power, flexibility, and versatility, GPT-3 is poised to have a major impact on the future of AI and technology.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;A brief history of GPT-3&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;GPT-3 is the latest iteration of the GPT (Generative Pre-trained Transformer) series of language models developed by OpenAI. The first GPT model was introduced in 2018 and was quickly followed by GPT-2 in 2019. Both models were highly successful and generated significant excitement and interest in the AI and language technology communities. GPT-3, however, represents a major step forward in terms of capabilities and potential applications. With its vast amounts of training data, advanced deep neural network, and sophisticated language processing capabilities, GPT-3 has been described as a &quot;breakthrough&quot; in the field of AI and language technology. The introduction of GPT-3 has generated a great deal of excitement and anticipation in the AI community, and its potential impact on a wide range of industries is eagerly awaited.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Understanding GPT-3&amp;nbsp;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;GPT-3 is an advanced artificial intelligence language model developed by OpenAI. It utilizes deep learning algorithms and a massive amount of training data to generate human-like responses to natural language inputs. This allows it to perform a wide range of language-related tasks, such as text generation, translation, question answering, and summarization, among others. Its unique combination of processing power and advanced language capabilities make GPT-3 a highly versatile tool with the potential to revolutionize the way we interact with and use language technology.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;How GPT-3 works&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 works by utilizing a deep neural network and massive amounts of training data to generate human-like responses to natural language inputs. The model is trained on a vast amount of text data to learn patterns and relationships between words and phrases, allowing it to generate coherent and contextually appropriate responses to inputs.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Architecture and components of GPT-3&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;The GPT-3 architecture consists of a deep neural network known as a transformer. This network is trained on a massive amount of text data using unsupervised learning, meaning it generates its own labels based on patterns it recognizes in the data. The transformer network is composed of multiple layers of attention and feed-forward processing, allowing it to generate highly nuanced language responses.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;The difference between GPT-3 and other language models&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 is a major advancement over previous language models, both in terms of its training data size and the sophistication of its deep learning algorithms. Additionally, GPT-3 has been designed specifically to perform a wide range of language-related tasks, making it highly versatile compared to other language models. Its advanced processing capabilities, combined with its vast amounts of training data, make it the most advanced language model currently available.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Applications of GPT-3&amp;nbsp;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Chatbots and customer service&lt;/li&gt;&lt;li&gt;Content creation and writing&lt;/li&gt;&lt;li&gt;Translation and language processing&lt;/li&gt;&lt;li&gt;Natural language processing for various industries such as finance, legal, and healthcare&lt;/li&gt;&lt;li&gt;Question-answering systems&lt;/li&gt;&lt;li&gt;Personalized recommendation systems&lt;/li&gt;&lt;li&gt;Speech recognition and voice-activated technology&lt;/li&gt;&lt;li&gt;Sentiment analysis and emotion recognition&lt;/li&gt;&lt;li&gt;Text summarization and keyword extraction&lt;/li&gt;&lt;li&gt;Virtual writing assistants and text prediction software.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Detailed explanation for some of the applications:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Chatbots and customer service&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 has the ability to understand and respond to natural language inputs, making it ideal for use in chatbots for customer service. It can provide quick and accurate responses, reducing wait times and improving the overall customer experience.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Content creation&amp;nbsp;&lt;br /&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 is capable of generating high-quality content in a variety of styles and formats, making it a valuable tool for content creators. From articles to social media posts, GPT-3 can save time and effort while producing unique and engaging content.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Translation&amp;nbsp;&lt;br /&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 has the ability to translate between multiple languages, making it a valuable tool for businesses and organizations looking to expand their reach globally. Its advanced language processing capabilities allow for accurate and nuanced translations.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Research and data analysis&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 can assist with research and data analysis by processing and organizing large amounts of information. It can provide insights and findings in a fraction of the time it would take for humans to complete the same task.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Advantages of GPT-3&amp;nbsp;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;GPT-3 has a number of advantages that make it a top choice for various applications in AI and technology.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Natural language processing&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 has advanced natural language processing capabilities that make it possible for it to understand and respond to complex human language.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;High accuracy and speed&amp;nbsp;&lt;br /&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;With its powerful neural network, GPT-3 is able to deliver fast and accurate outputs, making it a reliable option for many applications.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;High-quality outputs&amp;nbsp;&lt;br /&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 is designed to produce high-quality outputs that are coherent, relevant, and engaging.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Cost-effective compared to other language models&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 is a cost-effective option compared to other language models, making it a popular choice for businesses and individuals looking to adopt AI technology.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Challenges of GPT-3&amp;nbsp;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;The challenges of GPT-3 lie in ensuring ethical use of the technology and addressing potential negative consequences, such as the generation of fake news and misinformation. Additionally, there are concerns around privacy and data protection, as GPT-3 processes large amounts of personal information. Furthermore, the scalability and integration of GPT-3 into various industries also pose challenges, as well as the need for more robust and diverse training data to improve the language model&#39;s accuracy and inclusivity.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Measure challenge:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Privacy and data security&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;As GPT-3 is a highly advanced AI model that utilizes large amounts of data, privacy and data security are a major concern. There are concerns about the collection and use of personal data by GPT-3, and the potential misuse of that data. It is important to ensure that the data used to train GPT-3 is collected and processed in a secure and ethical manner to protect users&#39; privacy.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Bias and ethical considerations&amp;nbsp;&lt;br /&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;AI models like GPT-3 can perpetuate and amplify biases that exist in the data they are trained on. This can lead to unfair and unjust outcomes for certain groups of people. It is crucial to ensure that the training data used for GPT-3 is diverse and free from biases, and to address any biases that may arise in the outputs generated by the model.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Need for human oversight&lt;/h3&gt;&lt;div&gt;&lt;div&gt;While GPT-3 can perform many tasks with high accuracy and speed, it is still limited by the data it has been trained on. There is a need for human oversight to ensure that the outputs generated by GPT-3 are accurate, ethical, and aligned with the goals of the user. Additionally, as GPT-3 is a complex AI model, there is a need for experts to monitor and maintain the model to ensure it continues to function as intended.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Future of GPT-3&amp;nbsp;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;The future of GPT-3 is very promising as it is paving the way for new advancements in the field of AI and NLP. With its powerful language generation capabilities and ability to perform various tasks with high accuracy, it has the potential to revolutionize multiple industries. However, it is crucial to address and mitigate the challenges associated with the technology, such as privacy concerns and ethical considerations, to ensure its responsible usage. The advancements in GPT-3 and its integration with other technologies hold the key to unlocking a world of possibilities in the near future.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Advancements in language models&amp;nbsp;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;The field of language models is rapidly evolving, and GPT-3 is one of the latest advancements in the field. With the increasing demand for natural language processing and AI-powered communication, language models like GPT-3 are becoming increasingly important. Advancements in this area are making language models more sophisticated and more capable of handling complex tasks.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Integration with other AI technologies&amp;nbsp;&lt;br /&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 is a powerful language model that can be integrated with other AI technologies to create more sophisticated systems. For example, GPT-3 can be integrated with computer vision systems to enable image captioning or with speech recognition systems to enable natural language interaction. The potential for integration with other AI technologies is vast and continues to grow as the field evolves.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Potential impact on various industries&lt;/h3&gt;&lt;div&gt;&lt;div&gt;GPT-3 has the potential to have a significant impact on various industries, including customer service, content creation, and data analysis. With its advanced natural language processing capabilities, GPT-3 can automate many manual tasks and improve the efficiency and accuracy of these processes. As a result, businesses across a range of industries are exploring ways to integrate GPT-3 into their operations.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;GPT-3 can be used in several ways, including:&lt;/h2&gt;&lt;div&gt;&lt;b&gt;Through an API: &lt;/b&gt;OpenAI offers access to GPT-3 through an API that developers can use to integrate its capabilities into their own applications.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Pre-built tools and applications: &lt;/b&gt;OpenAI has developed several pre-built tools and applications that make use of GPT-3, such as the OpenAI Codex, which allows users to generate code snippets based on natural language inputs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Interactive console: &lt;/b&gt;OpenAI provides an interactive console that allows users to test and experiment with GPT-3&#39;s capabilities by inputting text and receiving responses in real-time.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Fine-tuning: &lt;/b&gt;Developers can also fine-tune GPT-3 on their own data sets to customize its capabilities for specific use cases.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To use GPT-3, you will typically need an OpenAI API key, which can be obtained by signing up for access on the OpenAI website.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can visite office website and use here:&amp;nbsp;&lt;/div&gt;&lt;div&gt;As chatgpt:&amp;nbsp;&lt;a href=&quot;https://chat.openai.com/chat&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://chat.openai.com/chat&lt;/a&gt;&lt;/div&gt;&lt;div&gt;As Interactive console:&amp;nbsp;&lt;a href=&quot;https://beta.openai.com/playground&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://beta.openai.com/playground&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Conclusion&amp;nbsp;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;GPT-3 is a cutting-edge language model developed by OpenAI that represents a major advance in the field of AI and language technology. Its powerful natural language processing capabilities and ability to perform a wide range of language-related tasks, such as text generation, translation, and question answering, make it a highly versatile tool with the potential to revolutionize a variety of industries. With its advanced deep neural network, vast amounts of training data, and sophisticated processing algorithms, GPT-3 is poised to have a major impact on the future of AI and technology. The potential applications of GPT-3 are vast, from customer service and content creation to education and healthcare, and its unique combination of power, flexibility, and versatility make it a tool that is likely to be highly sought after by a variety of organizations in the coming years.&lt;/div&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/8322659450822761992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2023/01/exploring-gpt-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8322659450822761992'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8322659450822761992'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2023/01/exploring-gpt-3.html' title='Exploring the Power and Potential of GPT-3: The Next Generation of AI Technology'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMxsjQZJz6Qf2mYo3h7EdqaJVHv_AP-sr8C7AOLywrfksr-Ibz_S7D5B-jyXjZVhvoOH3VeO8uuOB5PZ2P-_hbIhzEo1c8OSs0kufZNir-LgilWZenTq6XBS5pbXFDQWhPDu9q5wRQ6RDIy1MipsW6OcA4SgmQGrdYwVuH1FYK926vxLpee4N4cGyV/s72-w640-h624-c/Exploring%20the%20Power%20and%20Potential%20of%20GPT-3_%20The%20Next%20Generation%20of%20AI%20Technology%20.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-867771381045300150</id><published>2022-12-04T15:04:00.025+05:30</published><updated>2023-06-30T21:59:10.477+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Artificial Intelligent"/><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><title type='text'>What are Artificial Intelligence and Machine Learning? Top 6 Machine Learning Libraries?</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;Artificial Intelligent:&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;Artificial intelligence (AI) is the simulation of human intelligence processes by machines, especially computer systems. These processes include learning (the acquisition of information and rules for using the information), reasoning (using the rules to reach approximate or definite conclusions), and self-correction.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNPf_z7juaS7XfTTr3gXMGezy5dFOSQgAB476PYodpxzzXb9QUQ47P7g_cTCDGce_bhFb-AmGPr_7G9SC3hmvlnV2Of5mlWekZOQuRrtyTRZ5BhgiIexAeVRnOvkofkOj41B4vBv238pVTXKviWpqoUPHiDNOMraoXwT3Gif-XSCwErBB5yRk2ArNu/s1024/Artificial%20Intelligent%20cute%20image.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;991&quot; data-original-width=&quot;1024&quot; height=&quot;619&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNPf_z7juaS7XfTTr3gXMGezy5dFOSQgAB476PYodpxzzXb9QUQ47P7g_cTCDGce_bhFb-AmGPr_7G9SC3hmvlnV2Of5mlWekZOQuRrtyTRZ5BhgiIexAeVRnOvkofkOj41B4vBv238pVTXKviWpqoUPHiDNOMraoXwT3Gif-XSCwErBB5yRk2ArNu/w640-h619/Artificial%20Intelligent%20cute%20image.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Machine Learning:&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;Machine learning is a subset of artificial intelligence that uses statistical techniques to give machines and systems the ability to “learn” from data without being explicitly programmed. It focuses on developing computer programs that can access data and use it to learn for themselves.&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Some of the most popular libraries:&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;Used in machine learning are TensorFlow, Keras, Scikit-Learn, PyTorch, Microsoft Cognitive Toolkit, and Apache MXNet.&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;TensorFlow:&lt;/h3&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;TensorFlow is an open source software library for numerical computation using dataflow graphs. It is a symbolic math library, and is also used for machine learning applications such as neural networks. With TensorFlow, we can build and train neural networks to detect and decipher patterns and correlations, and can be used for predictive analysis.&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;Using TensorFlow, we can create, train, and deploy machine learning models. We can use it to build, train and deploy deep learning models such as convolutional neural networks, recurrent neural networks, and long short-term memory networks. We can also use it to create and train models for natural language processing (NLP) tasks, such as text classification, sentiment analysis and question-answering.&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;The models we can train in TensorFlow include linear models, logistic regression, support vector machines, decision trees, random forests, and neural networks. We can also use TensorFlow to create and train deep learning models such as convolutional neural networks, recurrent neural networks, and long short-term memory networks.&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Keras:&lt;/h3&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Keras is an open source deep learning library written in Python. It is designed to enable fast experimentation with deep neural networks. It is capable of running on top of TensorFlow, Microsoft Cognitive Toolkit, Theano, or PlaidML.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With Keras, users can easily build and train powerful deep learning models. It provides a wide range of model architectures, such as convolutional neural networks, recurrent neural networks, and multi-layer perceptions, as well as tools for model optimization, data pre-processing, and model evaluation.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Keras can be used to train a variety of models, including convolutional neural networks (CNNs), recurrent neural networks (RNNs), and long short-term memory (LSTM) networks. It can also be used to build custom models to solve specific tasks. For example, Keras can be used to create a model to classify images, recognize text, or predict stock prices.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h3&gt;Scikit-Learn:&lt;/h3&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Scikit-Learn is a free software machine learning library for the Python programming language. It features various classification, regression and clustering algorithms including support vector machines, random forests, gradient boosting, k-means and DBSCAN, and is designed to interoperate with the Python numerical and scientific libraries NumPy and SciPy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With Scikit-Learn, you can build and evaluate machine learning models, such as supervised learning (classification and regression) algorithms and unsupervised learning algorithms (clustering). You can also optimize model hyperparameters using grid search, tune model selection and pre-processing using pipelines, and perform model selection and validation to improve accuracy and performance.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Some examples of the models that can be trained in Scikit-Learn include linear models (such as linear regression and logistic regression), ensemble methods (such as random forests and gradient boosting), and kernel-based methods (such as support vector machines and k-nearest neighbors).&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;PyTorch:&lt;/h3&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;div&gt;PyTorch is an open source machine learning library for Python, based on Torch, used for applications such as natural language processing. It provides a wide range of algorithms for deep learning and uses the power of GPUs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With PyTorch, users can build and train neural networks for tasks such as object recognition and natural language processing. It also supports distributed training, meaning that multiple GPUs can be used in parallel for faster training.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;PyTorch supports a wide range of models, including convolutional neural networks, recurrent neural networks, generative adversarial networks, and reinforcement learning. It also supports model deployment, allowing users to deploy their models in production environments.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Microsoft Cognitive Toolkit:&lt;/h3&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;div&gt;Microsoft Cognitive Toolkit (formerly known as CNTK) is an open-source, deep learning framework developed by Microsoft. It is used to train, evaluate and deploy deep learning models. It can be used to build and train models in a variety of popular machine learning frameworks, such as Caffe, TensorFlow, and PyTorch.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With Microsoft Cognitive Toolkit, users can build and train models for image, text, and time series data. It supports supervised, unsupervised, and reinforcement learning. It also supports both CPU and GPU training. The toolkit can be used for a variety of tasks, such as natural language processing, computer vision, speech recognition, and reinforcement learning.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The models supported by Microsoft Cognitive Toolkit include feedforward neural networks, convolutional neural networks, recurrent neural networks, and long short-term memory networks. The toolkit also supports transfer learning, which allows users to adapt pre-trained models for their own custom tasks.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Apache MXNet:&lt;/h3&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;div&gt;Apache MXNet is an open source deep learning framework designed for both efficiency and flexibility. It is optimized for both cloud and edge environments, allowing for easy deployment of models across a wide range of applications. It is also highly scalable, allowing for distributed training on multiple machines to improve training speed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With Apache MXNet, users can develop, train, and deploy deep learning models for a variety of applications, such as computer vision, natural language processing, and time series analysis. It also supports a wide range of model architectures, such as convolutional neural networks, recurrent neural networks, and graph neural networks.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The models that can be trained in Apache MXNet include convolutional neural networks, recurrent neural networks, graph neural networks, generative adversarial networks, and reinforcement learning algorithms.&lt;/div&gt;&lt;/div&gt;&lt;/h2&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/867771381045300150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/12/artificial-intelligence-and-machine-learning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/867771381045300150'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/867771381045300150'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/12/artificial-intelligence-and-machine-learning.html' title='What are Artificial Intelligence and Machine Learning? Top 6 Machine Learning Libraries?'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNPf_z7juaS7XfTTr3gXMGezy5dFOSQgAB476PYodpxzzXb9QUQ47P7g_cTCDGce_bhFb-AmGPr_7G9SC3hmvlnV2Of5mlWekZOQuRrtyTRZ5BhgiIexAeVRnOvkofkOj41B4vBv238pVTXKviWpqoUPHiDNOMraoXwT3Gif-XSCwErBB5yRk2ArNu/s72-w640-h619-c/Artificial%20Intelligent%20cute%20image.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-8281121050329958969</id><published>2022-12-03T10:23:00.003+05:30</published><updated>2023-01-29T00:45:07.425+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="number system"/><title type='text'>Explain the Binary, Octel, Decimal, and Hexadecimal number systems with examples in detail.</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Number Systems:&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGUOnchJDxjfouLrPJ9ndEeI3t0n8SfL2GrFSr3DLc8geuT4nHrk7oKSVPHhXif52M6iMyJExfyxhZSMVLuQciDs9vowNtFygEeyUD8T3E_t9qllqlkkw_zep9NHRDIzKkEFhll1-8ShZb4shACQh47mGjo28Ag3VRc-ylU8_mmPYIWGMZ6gkokdXC/s1024/Binary,%20Octel,%20Decimal,%20and%20Hexadecimal%20.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;994&quot; data-original-width=&quot;1024&quot; height=&quot;622&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGUOnchJDxjfouLrPJ9ndEeI3t0n8SfL2GrFSr3DLc8geuT4nHrk7oKSVPHhXif52M6iMyJExfyxhZSMVLuQciDs9vowNtFygEeyUD8T3E_t9qllqlkkw_zep9NHRDIzKkEFhll1-8ShZb4shACQh47mGjo28Ag3VRc-ylU8_mmPYIWGMZ6gkokdXC/w640-h622/Binary,%20Octel,%20Decimal,%20and%20Hexadecimal%20.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Binary Number System:&lt;/h3&gt;&lt;div&gt;The binary number system is a base 2 system that uses only two digits (0 and 1). Each digit is referred to as a bit. A single bit can represent two values, 0 and 1, and all numbers in the binary number system are represented by combinations of 1s and 0s. For example, the binary number 101 is represented as 1 four, 0 twos, and 1 one, or 4 + 0 + 1 = 5.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Octal Number System:&lt;/h3&gt;&lt;div&gt;The octal number system is a base 8 system that uses eight digits (0-7). The octal number system is commonly used in programming languages and is sometimes referred to as the base-8 number system. Each digit in an octal number can represent three values (0-7), and all numbers in the octal number system are represented by combinations of these digits. For example, the octal number 12 is represented as 1 eight and 2 ones, or 8 + 2 = 10.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Decimal Number System:&lt;/h3&gt;&lt;div&gt;The decimal number system is a base 10 system that uses ten digits (0-9). The decimal number system is the most commonly used number system and is sometimes referred to as the base-10 number system. Each digit in a decimal number can represent ten values (0-9), and all numbers in the decimal number system are represented by combinations of these digits. For example, the decimal number 23 is represented as 2 tens and 3 ones, or 20 + 3 = 23.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Hexadecimal Number System:&lt;/h3&gt;&lt;div&gt;The hexadecimal number system is a base 16 system that uses sixteen digits (0-9 and A-F). The hexadecimal number system is commonly used in computing and is sometimes referred to as the base-16 number system. Each digit in a hexadecimal number can represent sixteen values (0-9 and A-F), and all numbers in the hexadecimal number system are represented by combinations of these digits. For example, the hexadecimal number 1A is represented as 1 sixteen and 10 ones, or 16 + 10 = 26.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/8281121050329958969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/12/explain-binary-octel-decimal-hexadecimal.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8281121050329958969'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8281121050329958969'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/12/explain-binary-octel-decimal-hexadecimal.html' title='Explain the Binary, Octel, Decimal, and Hexadecimal number systems with examples in detail.'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGUOnchJDxjfouLrPJ9ndEeI3t0n8SfL2GrFSr3DLc8geuT4nHrk7oKSVPHhXif52M6iMyJExfyxhZSMVLuQciDs9vowNtFygEeyUD8T3E_t9qllqlkkw_zep9NHRDIzKkEFhll1-8ShZb4shACQh47mGjo28Ag3VRc-ylU8_mmPYIWGMZ6gkokdXC/s72-w640-h622-c/Binary,%20Octel,%20Decimal,%20and%20Hexadecimal%20.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-6626828687382612527</id><published>2022-09-07T11:00:00.024+05:30</published><updated>2022-09-07T11:00:00.155+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>Write a program to insert the element at the given index in an array or list | MindTap Computing for Malik&#39;s C++ Programming 8th Edition</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;Write a function, insertAt, that takes four parameters: an array of integers, the number of elements in the array, an integer (say, insertItem),
and an integer (say, index). The function should insert Item in the
array at the position specified by index. If index is out of range, output an
appropriate message.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;Source:&lt;/b&gt;&amp;nbsp;&lt;span face=&quot;Lato, sans-serif&quot; style=&quot;background-color: #fffff3; font-size: 14px; white-space: pre-line;&quot;&gt;MindTap Computing for Malik&#39;s C++ Programming From Problem Analysis to Program Design, 8th Edition, [Instant Access] (8th)-Malik, chapter 16, programming exercises 7.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Solved!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt; text-align: justify;&quot;&gt;The
objective of the programming exercise is to write a function that takes 4
arguments array, size of the array, the index where the element will be
inserted, element to be inserted. and insert elements to the index given in the
array. size of the array will be incremented.&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program:&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;font-size: 15.4px; line-height: 20px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// write function that takes 4 argument array, size of the array,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// index where the element will be inserted, element to be inserted.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// and insert element to index given in the array. size of the array will be incremented.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// insertAt() that takes array, array size, index and insertItem.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// and insert elemnet at index given&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;insertAt&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[], &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;insertItem&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // is index is less than 0.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // print this msg.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Index can not be less than 0!&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // else if index is greater than or equal to n.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt; &amp;gt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // print this msg.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Index can not be greater than or equal to &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;!&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; } &amp;nbsp; &lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // increment size of array n.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // initialize j to n.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // use while loop j form n to index with decrement of 1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; &amp;gt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // assign value of previous element to current element.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // decrement of 1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;--;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // assign insertItem to arr[index]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // (insert at index.)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;insertItem&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// driver code.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // declare array size.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter array size(&amp;lt;=1000): &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // take user input for n.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // declare array with size 1000.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1000&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter array element&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // take user input using for loop.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // declare index, insertItem&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;insertItem&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // take user input .&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter index where element to be inserted: &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter element needed to insert at &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; index: &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;insertItem&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // calling function insertAt.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;insertAt&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;insertItem&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // print array using for loop.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;After inserting element &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;insertItem&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; at &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; index: &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;] &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // end.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Output:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjceRvO5qqdALQ33qqsbxf6kvMp-5YcKXnW_3zTq9L1j78REajaGv0zyV3cKCohd-koEo-V0S7T1xJVmIn20x-pSzACeVAkn3mNx3A6aIfpIsEq3BQpFtIdwB1yQfr_H9-ZhI4Mjmm1S79FHbwjPOcvIewrFuq_f58i1DlQQapL6jDLabpKTONQ_d9L&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;174&quot; data-original-width=&quot;471&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjceRvO5qqdALQ33qqsbxf6kvMp-5YcKXnW_3zTq9L1j78REajaGv0zyV3cKCohd-koEo-V0S7T1xJVmIn20x-pSzACeVAkn3mNx3A6aIfpIsEq3BQpFtIdwB1yQfr_H9-ZhI4Mjmm1S79FHbwjPOcvIewrFuq_f58i1DlQQapL6jDLabpKTONQ_d9L=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgQE8gSkjM9v1_xZgnksWlIqyQfaSDmgPaDRTByZqauAX2seHqujbsuFvJQ6UTRF6jv_KeHBgBCI1GicIsRyD9e_1gP2a_II762CWYwCdup3LOd9Qv0Owhgvqqujy2LknyDaQT5G0rLKWMnDG8mFSHc5DhrIHhF9KMgVsA1HE0BLjGkP5H6e1hDYBjS&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;317&quot; data-original-width=&quot;580&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgQE8gSkjM9v1_xZgnksWlIqyQfaSDmgPaDRTByZqauAX2seHqujbsuFvJQ6UTRF6jv_KeHBgBCI1GicIsRyD9e_1gP2a_II762CWYwCdup3LOd9Qv0Owhgvqqujy2LknyDaQT5G0rLKWMnDG8mFSHc5DhrIHhF9KMgVsA1HE0BLjGkP5H6e1hDYBjS=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjCuwZtdxJ6NB1aRCc0xWC3dmzJbHbIOXnHGSl7fL2mxqm-DJQZi2XK2ZdN2oqNOBKucsvDaGumNMIUmkE9FRFcRWjJMZcGD26mwKY0J2xWKsxUjuEZ7SHXfkNfjESrwkAKfggXlRMuKYEm-3moTLmijwOi2iVshdBxkPKCPYWSWweXdy4yGnaxk9LG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;418&quot; data-original-width=&quot;823&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjCuwZtdxJ6NB1aRCc0xWC3dmzJbHbIOXnHGSl7fL2mxqm-DJQZi2XK2ZdN2oqNOBKucsvDaGumNMIUmkE9FRFcRWjJMZcGD26mwKY0J2xWKsxUjuEZ7SHXfkNfjESrwkAKfggXlRMuKYEm-3moTLmijwOi2iVshdBxkPKCPYWSWweXdy4yGnaxk9LG=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Image:&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj3NjkuiqfGkdRTztVm8Oq9oKeFbOa2KxXPOBdgxpL4MAvL99U7_bp1yM6tGkNYoD3JxSoMx5QM_dpNehhrs3DD6NCqGMrrOT0ect5Wz5Qs6V2OlMBy8tEjP7msHkqQz5cDG9LPX9uF6tm8-2aihbIHOAQ0cv2mpA4CzKKy6M4DkmiRPWHk9DjxNPh0&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1564&quot; data-original-width=&quot;764&quot; height=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj3NjkuiqfGkdRTztVm8Oq9oKeFbOa2KxXPOBdgxpL4MAvL99U7_bp1yM6tGkNYoD3JxSoMx5QM_dpNehhrs3DD6NCqGMrrOT0ect5Wz5Qs6V2OlMBy8tEjP7msHkqQz5cDG9LPX9uF6tm8-2aihbIHOAQ0cv2mpA4CzKKy6M4DkmiRPWHk9DjxNPh0&quot; width=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhauv855SBrrC9HwlOqxaEQV9l8PKEJ-hUVuA2fgsNaugnjXrY8v1XloxxBTIjkxDGD7zwQlICkLoYcZ1IL51ki9fdSAj7ekvbwMofYTZz2Jzs-655Qliy47b2-rcdrC3GSbSo4YqIKuWhiq7oWpqTa-gQe_BXhrHT59f1jXRTVPWkjhloI7YH7Mbog&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1564&quot; data-original-width=&quot;764&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhauv855SBrrC9HwlOqxaEQV9l8PKEJ-hUVuA2fgsNaugnjXrY8v1XloxxBTIjkxDGD7zwQlICkLoYcZ1IL51ki9fdSAj7ekvbwMofYTZz2Jzs-655Qliy47b2-rcdrC3GSbSo4YqIKuWhiq7oWpqTa-gQe_BXhrHT59f1jXRTVPWkjhloI7YH7Mbog=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/6626828687382612527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/write-program-to-insert-element-at-given-index-in-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/6626828687382612527'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/6626828687382612527'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/write-program-to-insert-element-at-given-index-in-array.html' title='Write a program to insert the element at the given index in an array or list | MindTap Computing for Malik&#39;s C++ Programming 8th Edition'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEjceRvO5qqdALQ33qqsbxf6kvMp-5YcKXnW_3zTq9L1j78REajaGv0zyV3cKCohd-koEo-V0S7T1xJVmIn20x-pSzACeVAkn3mNx3A6aIfpIsEq3BQpFtIdwB1yQfr_H9-ZhI4Mjmm1S79FHbwjPOcvIewrFuq_f58i1DlQQapL6jDLabpKTONQ_d9L=s72-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>United States</georss:featurename><georss:point>37.09024 -95.712891</georss:point><georss:box>-36.862491167723185 123.66210899999999 90 44.912109</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-1616984526501818366</id><published>2022-09-06T11:00:00.013+05:30</published><updated>2022-09-06T11:00:00.146+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>Write a version of the selection sort algorithm that can be used to sort a list of strings | MindTap Computing for Malik&#39;s C++ Programming 8th Edition</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;&lt;div&gt;Write a version of the selection sort algorithm that can be used to sort a list
of strings.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;Source:&lt;/b&gt;&amp;nbsp;&lt;span face=&quot;Lato, sans-serif&quot; style=&quot;background-color: #fffff3; font-size: 14px; white-space: pre-line;&quot;&gt;MindTap Computing for Malik&#39;s C++ Programming From Problem Analysis to Program Design, 8th Edition, [Instant Access] (8th)-Malik, chapter 16, programming exercises 8.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Solved!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;The
objective of the programming exercise is to write a function to sort a given
list of strings using selection sort.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program Plan:&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt; text-indent: -18pt;&quot;&gt;Define
header section.&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; selectionSort(vector&amp;lt;string&amp;gt;
&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;arr) &lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;function
that take vector of string as pass by reference.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare array size &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; n =
arr.size()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Use for loop i from &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;0&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; to &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;n-2&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare
&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;
min_index = i&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;, tracks minimum element index in array&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; arr[i]...arr[n-1]&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Use for
loop j from &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;i+1
&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;to
&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;n-1&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 144.0pt; mso-add-space: auto; mso-list: l0 level4 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;If &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;arr[j]
&amp;lt; arr[min_index]&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 180.0pt; mso-add-space: auto; mso-list: l0 level5 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Assignment&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; j &lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;to&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; min_index&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Swap
element at index &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;i&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; and &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;min_index&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Define&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; main() &lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;function
(testing function).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt; int n &lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Take user input for list size &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;n&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;vector&amp;lt;string&amp;gt; arr(n)&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Take user input for strings using for
loop.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Call to function&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;
selectionSort()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Print the list of the string after sorting
using for loop.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;b style=&quot;text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;Program:&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;font-size: 15.4px; line-height: 20px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// write a function to sort a given list of strings using selection sort.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// selectionSort() that take vector of string as reference parameter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// and sort given list using selection sort algorithm.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;selectionSort&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // for loop i from 0 to n-2. &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set min_index to i.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // min_index tracks minimum element index in array arr[i]...arr[n-1].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_index&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if arr[j] is less than arr[min_index] .&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_index&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // assignment j to min_index.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_index&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // swap element at index i and min_index&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;swap&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_index&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// driver program.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // declare variable n.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter size of list of string: &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // take user input.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // declare vector arr of string of size n.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // take user input for arr vector using &amp;nbsp;for loop.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; words: &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // call to selection sort function.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;selectionSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // print array after sortting.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;List of string after selection sort: &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;, &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // end.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Output:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEizzC4iGYaaZkBYtzbMcY2lwsKoQIju8axm6g_AgLfHj_02UjwbNrwC2tzV5FktvK1o8jFNI4fpEaWWkWNpEmuHY_Swbc4b6V1GusGxJyJcG7MFqRuTs8kQqa_XGM9vQdpfrJFx-l4JW71s5RTlU4PPZexHWJGvvthwrerduDczHxxYfHixMAyT6LCf&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;188&quot; data-original-width=&quot;675&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEizzC4iGYaaZkBYtzbMcY2lwsKoQIju8axm6g_AgLfHj_02UjwbNrwC2tzV5FktvK1o8jFNI4fpEaWWkWNpEmuHY_Swbc4b6V1GusGxJyJcG7MFqRuTs8kQqa_XGM9vQdpfrJFx-l4JW71s5RTlU4PPZexHWJGvvthwrerduDczHxxYfHixMAyT6LCf=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgjMS760yexS8ce-C_-YiNuJDlHCc0-5EyT3TURYmYfbWwnVB6uKQRs6xVbvUc4YRPuIhaEJY0NPkv8QlK-pLU0dC4UF12wjizIajJVsefLcR31wEHgWjN3lQES68Cv1v0RLJ7PsANrqLNwK0_wnmoTIAHdHV8kw-iG-WnIZzOzZ3Rx-0IyaapstkSs&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;236&quot; data-original-width=&quot;684&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgjMS760yexS8ce-C_-YiNuJDlHCc0-5EyT3TURYmYfbWwnVB6uKQRs6xVbvUc4YRPuIhaEJY0NPkv8QlK-pLU0dC4UF12wjizIajJVsefLcR31wEHgWjN3lQES68Cv1v0RLJ7PsANrqLNwK0_wnmoTIAHdHV8kw-iG-WnIZzOzZ3Rx-0IyaapstkSs=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Image:&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiOGmN8ugpXiGUr9zkKW-3sSmnImtdBbnPMV5MJJo481L8TR8TxcEbPV8Fu6EbuzTHBEJ2DVn81dioP5jpS2Bhyv_2XwiT_vz0d4Ve5V3QqDgkWX5PnECBmYWjhRYCnnLB525LCRzBC5wT_DVsSLE6BHADWpjKTCdojihverFnartvp4sqsnrYJFE0B&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1260&quot; data-original-width=&quot;672&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiOGmN8ugpXiGUr9zkKW-3sSmnImtdBbnPMV5MJJo481L8TR8TxcEbPV8Fu6EbuzTHBEJ2DVn81dioP5jpS2Bhyv_2XwiT_vz0d4Ve5V3QqDgkWX5PnECBmYWjhRYCnnLB525LCRzBC5wT_DVsSLE6BHADWpjKTCdojihverFnartvp4sqsnrYJFE0B=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/1616984526501818366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/selection-sort-for-string-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/1616984526501818366'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/1616984526501818366'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/selection-sort-for-string-list.html' title='Write a version of the selection sort algorithm that can be used to sort a list of strings | MindTap Computing for Malik&#39;s C++ Programming 8th Edition'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEizzC4iGYaaZkBYtzbMcY2lwsKoQIju8axm6g_AgLfHj_02UjwbNrwC2tzV5FktvK1o8jFNI4fpEaWWkWNpEmuHY_Swbc4b6V1GusGxJyJcG7MFqRuTs8kQqa_XGM9vQdpfrJFx-l4JW71s5RTlU4PPZexHWJGvvthwrerduDczHxxYfHixMAyT6LCf=s72-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>United States</georss:featurename><georss:point>37.09024 -95.712891</georss:point><georss:box>23.412137286566022 -113.291016 50.768342713433981 -78.134766</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-3964620098861887753</id><published>2022-09-05T11:00:00.001+05:30</published><updated>2022-09-05T11:00:00.148+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="searching"/><title type='text'>Binary search algorithm that can be used to search a string vector object | MindTap Computing for Malik&#39;s C++ Programming 8th Edition</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;Write a version of the binary search algorithm that can be used to search a
string vector object. Also, write a program to test your algorithm.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;Source:&lt;/b&gt;&amp;nbsp;&lt;span face=&quot;Lato, sans-serif&quot; style=&quot;background-color: #fffff3; font-size: 14px; white-space: pre-line;&quot;&gt;MindTap Computing for Malik&#39;s C++ Programming From Problem Analysis to Program Design, 8th Edition, [Instant Access] (8th)-Malik, chapter 16, programming exercises 15.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Solved!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;The
objective of the programming exercise is to implement a binary search algorithm
to find string in&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;
vector&amp;lt;string&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; object which is sorted by selection sort.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program Plan:&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;/p&gt;&lt;/h2&gt;&lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l1 level1 lfo2; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Define
header section.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l1 level1 lfo2; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Define&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; selectionSort()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Define&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; binSearch()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; function which
takes array&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; arr&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; and
string&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; s&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;
left = 0&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;
and&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; right = arr.size() -1&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;While loop&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;
left &amp;lt;= right&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; m = (left + right) / 2&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;If&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; arr[m] == s&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 144.0pt; mso-add-space: auto; mso-list: l0 level4 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Found
element&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; s&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; in&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; arr&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; at index &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;m&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;, return&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; m&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Else if
&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;arr[m] &amp;lt; s&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 144.0pt; mso-add-space: auto; mso-list: l0 level4 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Set &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;left = m + 1&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Else if&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; arr[m] &amp;gt; s&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 144.0pt; mso-add-space: auto; mso-list: l0 level4 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Set&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; right = m - 1&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Return -1 if not return any value in the
while loop.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;main()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare n ask to take user input.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;vector&amp;lt;string&amp;gt;
arr&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;
of size &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;n&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Take user input to fill &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;arr&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare string &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;s&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; and
take user input for &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt;s&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Sort array using&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; selectionSort()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Print sorted array&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Find index&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; p&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; using&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt;&quot;&gt; binSearch()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; function call.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt; text-indent: -18pt;&quot;&gt;Print the result using if-else&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program:&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// objective of programming exercise is to implement binary search&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// algorithm to find string in vector&amp;lt;string&amp;gt; object which is sorted by selection sort.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// selectionSort() which take vector&amp;lt;string&amp;gt; pass by reference and sort it in ascending order.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;selectionSort&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // array size.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // for each index i from 0 to n-2.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // find minimum element index from i to n-1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_j&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_j&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // swap it with i index element.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;swap&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// binSeach() which takes vector&amp;lt;string&amp;gt; arr as pass by reference and s string.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// and return index of s in arr.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// if not found return -1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;binSeach&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // set left = 0 and right = arr size - 1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;left&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;right&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;() - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // while left is less or equal right.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;left&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;right&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // find mid point m&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt; = (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;left&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;right&lt;/span&gt;) / &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if arr[m] is equal to s.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // return m.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // else if arr[m] is less than s.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set left equal to m+1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;left&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // else if arr[m] is greate than s.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set right equal to m-1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;right&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // return -1 if not found.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; -&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// driver code.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // ask n array size.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter array size:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // fill vector&amp;lt;string&amp;gt; arr of n size by user input.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; number of strings:&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // taking word to search in vector.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter word you want to seach for in sorted vector:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // sort array.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;selectionSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // print sorted array.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Vector after sort:&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;, &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // find p index using function call.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;p&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;binSeach&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // if p is -1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;p&lt;/span&gt; == -&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // not found.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Entered word not found in vector.&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // else print p index.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Entered word found in vector at index &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;p&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Output:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgDB6vMnLsgC5WjIfDkOKags95d4KfoHO8ZDnvUi0pJUOOPYBFnX7VNAw65dFk3Zl_qhyoIwvICfYXADvUnLUJJEwcXYLGwJI4ltjoURZYKqY7b4Ys58XYBvquqnGtmAp0RYwZFPnh5KVPTpBFI2fwDmqBbhQDMJAT7k4dGK2vK_Ge84FLFktemYk2s&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;232&quot; data-original-width=&quot;521&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgDB6vMnLsgC5WjIfDkOKags95d4KfoHO8ZDnvUi0pJUOOPYBFnX7VNAw65dFk3Zl_qhyoIwvICfYXADvUnLUJJEwcXYLGwJI4ltjoURZYKqY7b4Ys58XYBvquqnGtmAp0RYwZFPnh5KVPTpBFI2fwDmqBbhQDMJAT7k4dGK2vK_Ge84FLFktemYk2s=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Image:&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhhqpBQ4ZyFD4FwaxMa98GjIIc95lBnnyohkbY_ZiexlZihDsMldMv1eqZnP_640nk3dCpoVeMgYPzo52d60b4BWd0yH1rHiRP6u8Q0l5QlVgEeNRfnkD8vdoqPsuu7IaaVwjzDF2TocLuo2E5tJMeJ_ym1fpv4yI-RW2WMY34uGRr4GFJLOwfChjQC&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;2140&quot; data-original-width=&quot;802&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhhqpBQ4ZyFD4FwaxMa98GjIIc95lBnnyohkbY_ZiexlZihDsMldMv1eqZnP_640nk3dCpoVeMgYPzo52d60b4BWd0yH1rHiRP6u8Q0l5QlVgEeNRfnkD8vdoqPsuu7IaaVwjzDF2TocLuo2E5tJMeJ_ym1fpv4yI-RW2WMY34uGRr4GFJLOwfChjQC=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/3964620098861887753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/binary-search-algorithm-that-can-be-used-to-search-string-vector.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3964620098861887753'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3964620098861887753'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/binary-search-algorithm-that-can-be-used-to-search-string-vector.html' title='Binary search algorithm that can be used to search a string vector object | MindTap Computing for Malik&#39;s C++ Programming 8th Edition'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgDB6vMnLsgC5WjIfDkOKags95d4KfoHO8ZDnvUi0pJUOOPYBFnX7VNAw65dFk3Zl_qhyoIwvICfYXADvUnLUJJEwcXYLGwJI4ltjoURZYKqY7b4Ys58XYBvquqnGtmAp0RYwZFPnh5KVPTpBFI2fwDmqBbhQDMJAT7k4dGK2vK_Ge84FLFktemYk2s=s72-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>United States</georss:featurename><georss:point>37.09024 -95.712891</georss:point><georss:box>9.5819625045790815 -130.869141 64.598517495420921 -60.556641</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-3955288441277700073</id><published>2022-09-04T11:00:00.012+05:30</published><updated>2022-09-04T11:00:00.158+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>Use bubble sort, selection sort, and insertion sort  to sort the array of 5000 elements and count the number of comparisons and assignments done in each sorting algorithm</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;Write a program that creates three identical arrays, list1, list2, and
list3 of 5,000 elements. The program then sorts list1 using bubble sort,&amp;nbsp;list2 using selection sort, and list3 using insertion sort and outputs
the number of comparisons and item assignments made by each sorting
algorithm.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;Source:&lt;/b&gt;&amp;nbsp;&lt;span face=&quot;Lato, sans-serif&quot; style=&quot;background-color: #fffff3; font-size: 14px; white-space: pre-line;&quot;&gt;MindTap Computing for Malik&#39;s C++ Programming From Problem Analysis to Program Design, 8th Edition, [Instant Access] (8th)-Malik, chapter 16, programming exercises 16.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Solved!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;The objective of the programming exercise is to create 3 identical arrays of size 5000 using&amp;nbsp;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;rand().&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&amp;nbsp;Sort first using bubble sort, second using selection sort, and third using insertion sort, Find the number of comparisons and assignments done for array element in each sorting algorithm. Print number of comparisons and assignments for every three sorting algorithms.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program Plan:&amp;nbsp;&lt;/h2&gt;

&lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; tab-stops: 143.25pt; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Define
header section.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; mso-list: l0 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;bubbleSort(&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; arr[], &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; n, &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;countComp, &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;countAssign)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; mso-list: l0 level1 lfo1; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;selectionSort(&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; arr[], &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; n, &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;countComp, &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;countAssign)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; tab-stops: 143.25pt; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;insertionSort(&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;
arr[], &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; n, &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;countComp, &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;countAssign)&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;main()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;
function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Set seed level for &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;rand()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;srand(time(&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;0&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;));&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare 3 array &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; l1[&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;MAX&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;], l2[&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;MAX&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;], l3[&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;MAX&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;].&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Use for loop &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;i&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; from 0 to &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;MAX-1.&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare
&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;
number = rand();&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12.0pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Initialize all element at index&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; &lt;b&gt;i &lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; &lt;b&gt;l1[i] = l2[i] = l3[i] = number&lt;/b&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; comp1 = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;0&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;, assign1 = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;0&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; &lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;call to &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;bubbleSort(l1, &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;MAX&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;,
comp1, assign1).&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; comp2 = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;0&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;, assign2 = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;0&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; &lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;call to&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;selectionSort (l1, &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;MAX&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;, comp2, assign2).&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72.0pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; comp3 = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;0&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;, assign3 = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;0&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt; &lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;call to&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;insertionSort (l1, &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;MAX&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;, comp3, assign3).&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; text-align: justify; text-indent: -18pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt; text-align: justify; text-indent: -18pt;&quot;&gt;Print the result using &lt;/span&gt;&lt;b style=&quot;text-align: justify; text-indent: -18pt;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12.0pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;cout &amp;lt;&amp;lt;.&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program:&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Objective of programming exercise create 3 identical array of size 5000 using rand().&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// sort first using bubbleSort, second using selectionSort, and third using insertionSort&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// find number of comparisons and assignment done for array element in each sorting algo.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// print number of comparison and assignment for each three sorting algo.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;ctime&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// define macro MAX 5000.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;MAX&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5000&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// bubbleSort().&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;bubbleSort&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[], &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;countComp&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;countAssign&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // for loop i from 0 to n-2.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // for loop j from 0 to n-2-i&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // increment comparison count.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countComp&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // comparing adjacent&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;] &amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // increment assignment count.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countAssign&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if arr[j] &amp;gt; arr[j+1] then swap.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;swap&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// selectionSort().&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;selectionSort&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[], &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;countComp&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;countAssign&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // for loop i from 0 to n-2.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set min_j to i.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // min_j keep track of minimum element index in array arr[i]...arr[n-1].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_j&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // increment comparison count.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countComp&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if arr[j] is less than arr[min_j] .&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;] &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_j&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // increment assignment count.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countAssign&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // assignment j to min_j.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_j&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // increment assignment count.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countAssign&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // swap element at index i and min_j&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;swap&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_j&lt;/span&gt;]);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// insertionSort().&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;insertionSort&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[], &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;countComp&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;countAssign&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // for loop i from 1 to n-1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // point is copy of element that has been inserted in sorted array arr[0]...arr[i].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;point&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set j &amp;nbsp;to i-1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // while j &amp;gt;= 0 and arr[j] &amp;gt; point.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; &amp;gt;= &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;] &amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;point&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // increment both counter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countComp&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countAssign&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // assignment arr[j+1] = arr[j].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // decrement j&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; -= &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set element at index j+1 to point.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countAssign&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;point&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // set seed level of rand() to time(0)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;srand&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;time&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // create 3 list.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l1&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;MAX&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l2&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;MAX&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l3&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;MAX&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // fill same random value in list.(create 3 identical array)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #569cd6;&quot;&gt;MAX&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;rand&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l1&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l2&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l3&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // call to each sorting function with corresponding list(array) as argument.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // store each result in pair.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;comp1&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;assign1&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;bubbleSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;l1&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;MAX&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;comp1&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;assign1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;comp2&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;assign2&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;selectionSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;l2&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;MAX&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;comp2&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;assign2&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;comp3&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;assign3&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;insertionSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;l3&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;MAX&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;comp3&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;assign3&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // print result.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Count Of &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Comparison&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Assignment&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;For Bubble Sort &amp;nbsp; &quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;comp1&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;assign1&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;For Selection Sort&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;comp2&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;assign2&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;For Insertion Sort&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\t&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;comp3&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;assign3&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // end.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Output:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEimhG1i5xhKJH-3fjEOTG7POMM_wFfIIFp5vCmUrm9oe2W_uhdI_qNFz2zs-XxhzRpb9Enw7Rx6p8yEoKSLHHVDYNdg63W3z9oxAJjo4uQUUKns-zuruk3hkLT3nJOu608mPENy1lBFlOhnuln7BzxNjy_tekKlVGTadLNG3lCtgR9dkIPBY_VOaYKT&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;86&quot; data-original-width=&quot;521&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEimhG1i5xhKJH-3fjEOTG7POMM_wFfIIFp5vCmUrm9oe2W_uhdI_qNFz2zs-XxhzRpb9Enw7Rx6p8yEoKSLHHVDYNdg63W3z9oxAJjo4uQUUKns-zuruk3hkLT3nJOu608mPENy1lBFlOhnuln7BzxNjy_tekKlVGTadLNG3lCtgR9dkIPBY_VOaYKT=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg5ugyanQAm0YMGxuJgKYSyi4sWQ4DSNXdRxi-5lbNmZiI_E-gdHplWy52uPYANWIU9nRYIQevXNOSgJbbRxYA6KXCvuntTEYfO3h9TtDGYr3Iyf-4PRxbL9a4bx-54inNkOKER807Ty_7548nctyIbSfGscn4XKRj2NmLHbcwV1fptQ5tgIV3VX_R2&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;87&quot; data-original-width=&quot;464&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg5ugyanQAm0YMGxuJgKYSyi4sWQ4DSNXdRxi-5lbNmZiI_E-gdHplWy52uPYANWIU9nRYIQevXNOSgJbbRxYA6KXCvuntTEYfO3h9TtDGYr3Iyf-4PRxbL9a4bx-54inNkOKER807Ty_7548nctyIbSfGscn4XKRj2NmLHbcwV1fptQ5tgIV3VX_R2=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Image:&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg-LRb8mdlrBKswhmllTTvl2AAeBqlyXUui4LEdncT3rq5E_YoY9F1pvwz6kF1vo_TnYq7G0ncFBZiUM36ah9PDGlvYSxVSl_VbkVBBx9uxqQYRMRUxXAHrimI-z8b8OXS5VY2ssAzT1jcGSas3SP9p_0QLje834MCmsmeeEPzWJjmC4W5VzA9aC4VN&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg-LRb8mdlrBKswhmllTTvl2AAeBqlyXUui4LEdncT3rq5E_YoY9F1pvwz6kF1vo_TnYq7G0ncFBZiUM36ah9PDGlvYSxVSl_VbkVBBx9uxqQYRMRUxXAHrimI-z8b8OXS5VY2ssAzT1jcGSas3SP9p_0QLje834MCmsmeeEPzWJjmC4W5VzA9aC4VN&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh7Y_bRHcb8BZOGs0M3FtZlhMPvs0_loMpKdDfu30hn9RH9IRY4OwaNjczs2tpUHg1zjqWmjGAifE6ohwEL1bcS7pYxjcDi53vFAuTJYg9eGdayulke0yz9YZ-AQKK20Z85-LOJ4nKIJLJwHPlblcl9hxAUeTg0fegYilwgHCvUjmKguCYyDnwcRAvD&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;2428&quot; data-original-width=&quot;780&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh7Y_bRHcb8BZOGs0M3FtZlhMPvs0_loMpKdDfu30hn9RH9IRY4OwaNjczs2tpUHg1zjqWmjGAifE6ohwEL1bcS7pYxjcDi53vFAuTJYg9eGdayulke0yz9YZ-AQKK20Z85-LOJ4nKIJLJwHPlblcl9hxAUeTg0fegYilwgHCvUjmKguCYyDnwcRAvD=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/3955288441277700073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/use-bubble-selection-insertion-sort-and-find-number-of-comparison-assignment-done-in-each-sorting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3955288441277700073'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3955288441277700073'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/use-bubble-selection-insertion-sort-and-find-number-of-comparison-assignment-done-in-each-sorting.html' title='Use bubble sort, selection sort, and insertion sort  to sort the array of 5000 elements and count the number of comparisons and assignments done in each sorting algorithm'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEimhG1i5xhKJH-3fjEOTG7POMM_wFfIIFp5vCmUrm9oe2W_uhdI_qNFz2zs-XxhzRpb9Enw7Rx6p8yEoKSLHHVDYNdg63W3z9oxAJjo4uQUUKns-zuruk3hkLT3nJOu608mPENy1lBFlOhnuln7BzxNjy_tekKlVGTadLNG3lCtgR9dkIPBY_VOaYKT=s72-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>United States</georss:featurename><georss:point>37.09024 -95.712891</georss:point><georss:box>8.780006163821156 -130.869141 65.400473836178847 -60.556641</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-8948660724383531811</id><published>2022-09-03T13:00:00.004+05:30</published><updated>2022-09-03T13:00:00.154+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>Write a program to improve the performance of the bubble sort program | MindTap Computing for Malik&#39;s C++ Programming 8th Edition</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;a. It was remarked in this chapter that the performance of bubble sort can
be improved if we stop the sorting process as soon as we find that in
an iteration no swapping of elements takes place. Write a function that
implements bubble sort algorithm using this fact. (2)&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;b. Using the algorithm that you designed in part (a), find the number of
iterations that are needed to sort the list: 65, 14, 52, 43, 75, 25,
80, 90, 95. (2)&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Write a program to test the function you designed in the above Exercise to improve
the performance of bubble sort.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Source:&lt;/b&gt;&amp;nbsp;&lt;span face=&quot;Lato, sans-serif&quot; style=&quot;background-color: #fffff3; font-size: 14px; white-space: pre-line;&quot;&gt;MindTap Computing for Malik&#39;s C++ Programming From Problem Analysis to Program Design, 8th Edition, [Instant Access] (8th)-Malik, chapter 16, programming exercises 17.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Solved!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;The
objective of this program is to improve the performance of the bubble sort function.
And test that function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;h2 style=&quot;line-height: normal; margin-bottom: 0cm; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Program Plan:&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Define the header section.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; bubbleSort(&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; arr[], &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; n)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Declare
&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;
countIter = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;0&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Use for loop i from 0 to n-2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 108pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Wingdings; font-size: 12pt;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;bool&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; swapped = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 108pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Wingdings; font-size: 12pt;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Use for loop j from 0 to n-2-i.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 144pt; mso-add-space: auto; mso-list: l0 level4 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;If&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;arr[j]
&amp;gt; arr[j + &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;1&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;] &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;is ture.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 180pt; mso-add-space: auto; mso-list: l0 level5 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Set &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;swapped = &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 180pt; mso-add-space: auto; mso-list: l0 level5 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Swap element at index&amp;nbsp; j and j+1
using &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;swap(arr[j], arr[j + &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;1&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;])&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 108pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Wingdings; font-size: 12pt;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;If&amp;nbsp; still &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;swapped
== &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;false &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 144pt; mso-add-space: auto; mso-list: l0 level4 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Break the loop using &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;break&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; mso-list: l0 level1 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; main()&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt; function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Declare array size &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; n;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Take using input using &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;cin &amp;gt;&amp;gt; n;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Declare array &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; arr[n];&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Take input for array using for loop with statement &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;cin
&amp;gt;&amp;gt; arr[i];&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; countIter = bubbleSort(arr, n)&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;function call.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;background: white; line-height: 14.25pt; margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Print sorted array using for loop with statement &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;cout
&amp;lt;&amp;lt; arr[i] &amp;lt;&amp;lt; &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #a31515; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-bidi-font-family: Consolas; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&quot;, &quot;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;div&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; text-indent: -18pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt; text-indent: -18pt;&quot;&gt;Print &lt;/span&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;countIter&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program:&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Object of this program is to improve the performance of the bubbleSort function.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// bubbleSort().&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;bubbleSort&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[], &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // counter for iteration.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countIter&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // use for loop i from 0 to n-2.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set swapped bool value to false.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;swapped&lt;/span&gt; = &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // increment Iteration counter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countIter&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // for loop j from 0 to n-2-i.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // check if jth element is greater than j+1th element.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;] &amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set swapped true.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;swapped&lt;/span&gt; = &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // and swap element.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;swap&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if swapped is still false.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;swapped&lt;/span&gt; == &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // break the loop.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // retrun countIter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countIter&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// driver code.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // take array size as input.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter array size:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // fill array with n user input.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; integers:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // call to bubbleSort() and store countIter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countIter&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;bubbleSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // print sorted array.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Array is sorted:&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;] &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;, &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // print needed iteration after to sort array improvement .&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Number of iteration required to sort array using bubble sort:&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;countIter&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // end.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Output:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhAIF4693YoJJgzNBZtMAMk62oHBIn_firfJ-Vus9fWyd0sreVrzB7AnsWKdhaT_HJbK3seB50xa1xBln8xvNbkAtpOZ4a-f1am7KqORu5DSEZitxc_c2x8MNmib7JnpoCWblLsPb9f0WUf5VZSU2KPX_rR3rstkxOyCa77cVuyaWjVJ9wx87D0gX5e&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;104&quot; data-original-width=&quot;573&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhAIF4693YoJJgzNBZtMAMk62oHBIn_firfJ-Vus9fWyd0sreVrzB7AnsWKdhaT_HJbK3seB50xa1xBln8xvNbkAtpOZ4a-f1am7KqORu5DSEZitxc_c2x8MNmib7JnpoCWblLsPb9f0WUf5VZSU2KPX_rR3rstkxOyCa77cVuyaWjVJ9wx87D0gX5e=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgw0ZvgTehoa2b5MhgGEUM64eT8Tbv7ssb-M6sATVaPlaCWEWA7ccioxmZXSqGRanpOvZcSiw5CypNe0OsuyLiFLh1_fXY4pM9AWBi0qjnaZwr7u-OroNBWDxrc57LIOVv0_KvzL4DXEehUi3fdC5e0X9b9QC5eGxd1o92DofP2V2vxqbvC6JLoUnhF&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;108&quot; data-original-width=&quot;633&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgw0ZvgTehoa2b5MhgGEUM64eT8Tbv7ssb-M6sATVaPlaCWEWA7ccioxmZXSqGRanpOvZcSiw5CypNe0OsuyLiFLh1_fXY4pM9AWBi0qjnaZwr7u-OroNBWDxrc57LIOVv0_KvzL4DXEehUi3fdC5e0X9b9QC5eGxd1o92DofP2V2vxqbvC6JLoUnhF=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Image:&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg-LRb8mdlrBKswhmllTTvl2AAeBqlyXUui4LEdncT3rq5E_YoY9F1pvwz6kF1vo_TnYq7G0ncFBZiUM36ah9PDGlvYSxVSl_VbkVBBx9uxqQYRMRUxXAHrimI-z8b8OXS5VY2ssAzT1jcGSas3SP9p_0QLje834MCmsmeeEPzWJjmC4W5VzA9aC4VN&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg-LRb8mdlrBKswhmllTTvl2AAeBqlyXUui4LEdncT3rq5E_YoY9F1pvwz6kF1vo_TnYq7G0ncFBZiUM36ah9PDGlvYSxVSl_VbkVBBx9uxqQYRMRUxXAHrimI-z8b8OXS5VY2ssAzT1jcGSas3SP9p_0QLje834MCmsmeeEPzWJjmC4W5VzA9aC4VN&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh3u3XKkGocZhJ5OxozKJGKTUJKTOpw_rtB1q4yT82Y1arthrebkEjDY7SOoqKMjGbToAqobHeQsIORBXihwscMc-uLoLq3SIeZJnzSDVMOE3BRF1Ts7buN0L0iLBQzVise-zlxqvgwAUDWzwvQ4MWs59QhRLMBIWUIA8nV-mhOApO7FD8fgqtRCyJN&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1386&quot; data-original-width=&quot;826&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh3u3XKkGocZhJ5OxozKJGKTUJKTOpw_rtB1q4yT82Y1arthrebkEjDY7SOoqKMjGbToAqobHeQsIORBXihwscMc-uLoLq3SIeZJnzSDVMOE3BRF1Ts7buN0L0iLBQzVise-zlxqvgwAUDWzwvQ4MWs59QhRLMBIWUIA8nV-mhOApO7FD8fgqtRCyJN=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg-LRb8mdlrBKswhmllTTvl2AAeBqlyXUui4LEdncT3rq5E_YoY9F1pvwz6kF1vo_TnYq7G0ncFBZiUM36ah9PDGlvYSxVSl_VbkVBBx9uxqQYRMRUxXAHrimI-z8b8OXS5VY2ssAzT1jcGSas3SP9p_0QLje834MCmsmeeEPzWJjmC4W5VzA9aC4VN&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/8948660724383531811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/write-program-to-improve-performance-of-bubble-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8948660724383531811'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8948660724383531811'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/09/write-program-to-improve-performance-of-bubble-sort.html' title='Write a program to improve the performance of the bubble sort program | MindTap Computing for Malik&#39;s C++ Programming 8th Edition'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhAIF4693YoJJgzNBZtMAMk62oHBIn_firfJ-Vus9fWyd0sreVrzB7AnsWKdhaT_HJbK3seB50xa1xBln8xvNbkAtpOZ4a-f1am7KqORu5DSEZitxc_c2x8MNmib7JnpoCWblLsPb9f0WUf5VZSU2KPX_rR3rstkxOyCa77cVuyaWjVJ9wx87D0gX5e=s72-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>United States</georss:featurename><georss:point>37.09024 -95.712891</georss:point><georss:box>8.780006163821156 -130.869141 65.400473836178847 -60.556641</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-8231648400665762212</id><published>2022-08-29T09:22:00.002+05:30</published><updated>2022-09-01T10:34:49.090+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>Write a function that rearranges a given descending order array into ascending order without using any sorting algorithm</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;Suppose that the elements of a list are in descending order and they
need to be put in ascending order. Write a C++ function that takes an array of items in descending order and the number of elements in the array as input. The function rearranges the elements of the array
in ascending order. Your function must not incorporate any sorting
algorithms, that is, no item comparisons should take place.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;Source:&lt;/b&gt;&amp;nbsp;&lt;span face=&quot;Lato, sans-serif&quot; style=&quot;background-color: #fffff3; font-size: 14px; white-space: pre-line;&quot;&gt;MindTap Computing for Malik&#39;s C++ Programming From Problem Analysis to Program Design, 8th Edition, [Instant Access] (8th)-Malik, chapter 16, programming exercises 18.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Solved!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This program aims to write a function that rearranges a given descending order array into ascending order without using any sorting algorithm.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program Plan:&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Define program
header.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;rearrange() &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;which take
arguments &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; arr[], &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; n&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;For loop &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;i&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; from 0 to &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;n/2&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108pt; mso-add-space: auto; mso-list: l0 level3 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Wingdings; font-size: 12pt; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;&quot;&gt;§&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Swap &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;ith&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; and &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;ith&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; last element
using &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;swap(arr[i],
arr[n - &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: #098658; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;1&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; - i]);&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;main()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;
function. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;int n&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; variable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Use &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;cout &amp;lt;&amp;lt;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; to ask
the user to input.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Use &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;cin &amp;gt;&amp;gt; n&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; to
take user input.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Declare array &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;arr[]&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; of size &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;n&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;, this
input should be in sorted order.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Use for loop to take user input.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Make function call &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;rearrange(arr, n);&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Use for loop to print each element using &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;cout&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program:&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Object of this program is to write the function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// which rearrange given descending order array into ascending order&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// without using any sorting algorithm&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;#include &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; std;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// rearrange() function which take array and array size.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; rearrange(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; arr[], &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; n)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // for loop for half value of n.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // for loop i from 0 to n/2-1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; i = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; i &amp;lt; n / &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;; i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // swap ith element with ith last element.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; swap(arr[i], arr[n - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt; - i]);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// driver function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; main()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // ask array size.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; n;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter number of integers:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; n;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // fill array of size n with user input.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; arr[n];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter &quot;&lt;/span&gt; &amp;lt;&amp;lt; n &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; integers in descending order:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; i = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; i &amp;lt; n; i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // fill each element.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cin &amp;gt;&amp;gt; arr[i];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // call to rearrange.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; rearrange(arr, n);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // print array after rearrangement.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Array after rearrangement:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; i = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; i &amp;lt; n; i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; arr[i] &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;, &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; endl;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // end.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Output:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhRrf-UbgKi-T0LgkP0if3UMBRsjL8mcq4sISs7mpPxlROChLw1Wv2wcW3LIDoyqgXD5ssdTuO2Mi674KBnwyeyA0aNwZpZzklvwgNel-LTvhiULaY74nOAgS3ILe6Kc6MORcoKxcSwQufZSRs3y51SHjmWxNNeh4er0CBoV0uMPyLSPu8OS7xtwr8v&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;102&quot; data-original-width=&quot;549&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhRrf-UbgKi-T0LgkP0if3UMBRsjL8mcq4sISs7mpPxlROChLw1Wv2wcW3LIDoyqgXD5ssdTuO2Mi674KBnwyeyA0aNwZpZzklvwgNel-LTvhiULaY74nOAgS3ILe6Kc6MORcoKxcSwQufZSRs3y51SHjmWxNNeh4er0CBoV0uMPyLSPu8OS7xtwr8v=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjx0SVeMZQ9HysfM1FpZ99TdHHguMVKp_b3lpYxoNjb3eER1PMKgxGrZXmQ3pd0GUqFq9jA2sQwTzz-BppbwgQCVXLxA5VnqALCOSYwPAw9eGrc-FREoBatyrpRKDDuP5zkR75_h-jF2uCIidABiWGbIK--1MNu0zhvVNhev7cI7mmJ4orMAzdXCqXJ&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;112&quot; data-original-width=&quot;755&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjx0SVeMZQ9HysfM1FpZ99TdHHguMVKp_b3lpYxoNjb3eER1PMKgxGrZXmQ3pd0GUqFq9jA2sQwTzz-BppbwgQCVXLxA5VnqALCOSYwPAw9eGrc-FREoBatyrpRKDDuP5zkR75_h-jF2uCIidABiWGbIK--1MNu0zhvVNhev7cI7mmJ4orMAzdXCqXJ=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Image:&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg-LRb8mdlrBKswhmllTTvl2AAeBqlyXUui4LEdncT3rq5E_YoY9F1pvwz6kF1vo_TnYq7G0ncFBZiUM36ah9PDGlvYSxVSl_VbkVBBx9uxqQYRMRUxXAHrimI-z8b8OXS5VY2ssAzT1jcGSas3SP9p_0QLje834MCmsmeeEPzWJjmC4W5VzA9aC4VN&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img data-original-height=&quot;1970&quot; data-original-width=&quot;1132&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg-LRb8mdlrBKswhmllTTvl2AAeBqlyXUui4LEdncT3rq5E_YoY9F1pvwz6kF1vo_TnYq7G0ncFBZiUM36ah9PDGlvYSxVSl_VbkVBBx9uxqQYRMRUxXAHrimI-z8b8OXS5VY2ssAzT1jcGSas3SP9p_0QLje834MCmsmeeEPzWJjmC4W5VzA9aC4VN=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/8231648400665762212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/08/write-function-that-rearranges-given-ascending-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8231648400665762212'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8231648400665762212'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/08/write-function-that-rearranges-given-ascending-array.html' title='Write a function that rearranges a given descending order array into ascending order without using any sorting algorithm'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEhRrf-UbgKi-T0LgkP0if3UMBRsjL8mcq4sISs7mpPxlROChLw1Wv2wcW3LIDoyqgXD5ssdTuO2Mi674KBnwyeyA0aNwZpZzklvwgNel-LTvhiULaY74nOAgS3ILe6Kc6MORcoKxcSwQufZSRs3y51SHjmWxNNeh4er0CBoV0uMPyLSPu8OS7xtwr8v=s72-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>United States</georss:featurename><georss:point>37.09024 -95.712891</georss:point><georss:box>8.780006163821156 -130.869141 65.400473836178847 -60.556641</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-2311889859665993788</id><published>2022-08-28T09:42:00.002+05:30</published><updated>2022-09-01T10:34:29.986+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="Recursion"/><title type='text'>Recursive Version Of The Binary Search</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; text-align: justify;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;The
objective of the program is to write a recursive version of the binary search.
And write a program to test it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;Source:&lt;/b&gt;&amp;nbsp;&lt;span style=&quot;background-color: #fffff3; font-family: Lato, sans-serif; font-size: 14px; white-space: pre-line;&quot;&gt;MindTap Computing for Malik&#39;s C++ Programming From Problem Analysis to Program Design, 8th Edition, [Instant Access] (8th)-Malik, chapter 16, programming exercises 19.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Solved!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program Plan:&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;p class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Define
header section.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol; font-size: 12pt;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;binSearch()&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;fuction with
parameter &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; arr[], &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; left, &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; right, &lt;/span&gt;&lt;span style=&quot;color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-ansi-language: EN-IN; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt; key.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;If left become
is greater than right return &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;-1.&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Declare and Find
mid &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;mid = (left + right) / 2&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;If &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;arr[mid]&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt; is key return &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;mid&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt; index.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Else if &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;arr[mid] &amp;gt; key&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt; return function call &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;binSeach(arr, left, mid-1, key)&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt; for left array search.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt;Else return
function call &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt;&quot;&gt;binSeach(arr,
mid + 1, right, key)&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;, serif; font-size: 12pt;&quot;&gt; for righ array
search.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Symbol; font-size: 12pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Define &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;main()&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;
function.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;n&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Ask user to input array size.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Use &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;cin &amp;gt;&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; to
take input.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Declare array &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;arr&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; of size &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;n&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Take user input for array for &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;arr&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Declare &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;key&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Take user input for &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;key&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Call to &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;binSearch(arr, 0, n - 1, key)&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; and
declare &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;p&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt; to
store return value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 72pt; mso-add-space: auto; mso-list: l0 level2 lfo1; text-align: justify; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;o&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 12pt;&quot;&gt;Print result.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Program:&amp;nbsp;&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// Object of program is to write recursive version of binary search.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// binSeach() which take arr[], left, right and key as argument.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;binSeach&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[], &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;left&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;right&lt;/span&gt;, &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // if left become is greater than right.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;left&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;right&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // return -1 (not found)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; -&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // find mid.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt; = (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;left&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;right&lt;/span&gt;) / &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // if arr[mid] is key.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;] == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // return mid (found at mid index.)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // arr[mid] &amp;gt; key then&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;] &amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // search left half&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // return call binSeach(arr, left, mid-1, key)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;binSeach&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;left&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // search right half&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // return call binSeach(arr, mid+1, right, key)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;binSeach&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;right&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// drive function.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // declare n array size.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter array size:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // ask array size.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // fill array.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; number of integers in sorted in ascending order:&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // taking user input for each array cell.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // declare key.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter key integer you want to seach for in sorted array:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // take key to search.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // call to binSeach() with argument arr, 0, n-1, key&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;p&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;binSeach&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // print result.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;p&lt;/span&gt; == -&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Entered integer not found in array.&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Entered integer found in array at index &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;p&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;Output:&lt;/h2&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjqyp_1KhWiM21iAvJ5K-_cEhRDzk16BHx8DDaoy5HEoOr_qTVpKP3hvl6g9ETn-TY42DIvLSNe_1CVEWiCNx5QIMJ-9qYnPTo4Vabn20fS4ZbRQUrW4FbBHxEuaz__tPnrdiPxRgmHI4cnIByLps1jCUgyGKFIPI7RGsP2RpXIbqgO3RngjNucAkE9&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjqyp_1KhWiM21iAvJ5K-_cEhRDzk16BHx8DDaoy5HEoOr_qTVpKP3hvl6g9ETn-TY42DIvLSNe_1CVEWiCNx5QIMJ-9qYnPTo4Vabn20fS4ZbRQUrW4FbBHxEuaz__tPnrdiPxRgmHI4cnIByLps1jCUgyGKFIPI7RGsP2RpXIbqgO3RngjNucAkE9&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgEGsPNyrERfCA0LXcFltAG3YYuAkeEntViNLZe7jXc2GDWlivAZKBAoNaO4IpFcykdZxVa0Dn7g7CgdJS3AFu28p6X0p1BuweTAbAF4MsF994j8h-bXw04ZxZU_qdRU7NJKZwDiQFl4sZq-NzWwpRBPz0AnxSV4WxmO_f8GqY9AgiPed4nN7WbjJQ-&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;141&quot; data-original-width=&quot;641&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgEGsPNyrERfCA0LXcFltAG3YYuAkeEntViNLZe7jXc2GDWlivAZKBAoNaO4IpFcykdZxVa0Dn7g7CgdJS3AFu28p6X0p1BuweTAbAF4MsF994j8h-bXw04ZxZU_qdRU7NJKZwDiQFl4sZq-NzWwpRBPz0AnxSV4WxmO_f8GqY9AgiPed4nN7WbjJQ-=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhri1V89Y7HnZb1IsO99h8EzzE43gGXxF_w2NdFvqCMlKcq1Lemm1MlKt3pponPY4C6FgdGyQPJ1AFAbrXwfdqn8Ue7qnponUvtaaAnY0UIkWsagxmpltWJySb7q23ZvOl0hRmiIAfcERgyGW3IVMDB6_GWELF8avUSz9gIigoOf8RYWVqmvsdRHP4k&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;176&quot; data-original-width=&quot;706&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhri1V89Y7HnZb1IsO99h8EzzE43gGXxF_w2NdFvqCMlKcq1Lemm1MlKt3pponPY4C6FgdGyQPJ1AFAbrXwfdqn8Ue7qnponUvtaaAnY0UIkWsagxmpltWJySb7q23ZvOl0hRmiIAfcERgyGW3IVMDB6_GWELF8avUSz9gIigoOf8RYWVqmvsdRHP4k=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Image:&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj6K0mbOib9dg82VtCK3GRbiEM_jjyiHBEvLVlOHNibdUn7B4IBpZxuze83I7OjInuPsXj7UBQX8mUF0Q0UGzNgVagR01Hc6KcVQcaYKwFCJDI0qycCy06b0Pam1TKoIAaCqUjOzWvUBzPUJAH-QWIU98aAXfd4OHcicJ4DiCA9sbGlNvbm0QfxKflp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;2998&quot; data-original-width=&quot;1458&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEj6K0mbOib9dg82VtCK3GRbiEM_jjyiHBEvLVlOHNibdUn7B4IBpZxuze83I7OjInuPsXj7UBQX8mUF0Q0UGzNgVagR01Hc6KcVQcaYKwFCJDI0qycCy06b0Pam1TKoIAaCqUjOzWvUBzPUJAH-QWIU98aAXfd4OHcicJ4DiCA9sbGlNvbm0QfxKflp=s16000&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/2311889859665993788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/08/recursive-version-of-binary-search.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/2311889859665993788'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/2311889859665993788'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/08/recursive-version-of-binary-search.html' title='Recursive Version Of The Binary Search'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgEGsPNyrERfCA0LXcFltAG3YYuAkeEntViNLZe7jXc2GDWlivAZKBAoNaO4IpFcykdZxVa0Dn7g7CgdJS3AFu28p6X0p1BuweTAbAF4MsF994j8h-bXw04ZxZU_qdRU7NJKZwDiQFl4sZq-NzWwpRBPz0AnxSV4WxmO_f8GqY9AgiPed4nN7WbjJQ-=s72-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-25.096146123231282 8.6503799999999984 66.283514123231285 149.27537999999998</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-6111277066415418017</id><published>2022-02-15T12:03:00.002+05:30</published><updated>2022-02-15T12:03:21.496+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Secant Method Python With Desired Accuracy</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;We are given a function and one interval a to b we have to find the solution of function f(x) for which f(x0) = 0.&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Why is Secant Method:&amp;nbsp;&lt;/h2&gt;&lt;div&gt;We know some equations like quadratic equations and cubic equations are solvable if a solution exists. but for some complex equations solution exists but it is complex to solve them using normal maths.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Secant Method:&lt;/h2&gt;&lt;div&gt;Let, f(x) is given, and interval a to b is given. we want to find value of x = x0 where f(x0) = 0.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) If f(a) * f(b) &amp;gt;= 0:&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; Solution doesn&#39;t exists.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;2) Find x using this&amp;nbsp;&lt;/span&gt;x = a - f(a) * (b-a) / (f(b)-f(a))&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; find f(x) for this x.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;3) if f(a) * f(x) &amp;lt; 0:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; Update&lt;/span&gt;&amp;nbsp;b = x&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; Else if f(x) * f(b) &amp;lt; 0:&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp; &amp;nbsp; Update a = x&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; Else if f(x) == 0:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; x is solution.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; Else:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; The solution doesn&#39;t exist.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;4) Repeat steps 2) and 3) until we get desired accuracy.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp-ZCjvwx-wdAqLeQE0IpNswLaCYORsB1OPF9tzyWg9TwUsMQXUoLOaLshedNtIYfWpZQxDDJIw43JX8g5l_Phrqmkny34DEVB2-c-zbGuSD_0atHIr2tmG4zDFS0wo26YSpw7kAB76wo/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp-ZCjvwx-wdAqLeQE0IpNswLaCYORsB1OPF9tzyWg9TwUsMQXUoLOaLshedNtIYfWpZQxDDJIw43JX8g5l_Phrqmkny34DEVB2-c-zbGuSD_0atHIr2tmG4zDFS0wo26YSpw7kAB76wo/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi-4Tm2SGI3ZnVj4T-0PtFBOQ9CitiDNHS89QB6PBo_DdYwWfxAczWE7Iwh5PpHP5t-pBQzm7oylfzYi3BGGZVErWUd1rJ-YifRpfVLD-YaVt1_fTvHJWytRkZi-EsagdaniPVBlvmgGfMEeEwz4hgJmgWblBOjk8YAg_tmp_RD_vtDh4VSCwb1A2Ww&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;solving equations&quot; data-original-height=&quot;311&quot; data-original-width=&quot;616&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi-4Tm2SGI3ZnVj4T-0PtFBOQ9CitiDNHS89QB6PBo_DdYwWfxAczWE7Iwh5PpHP5t-pBQzm7oylfzYi3BGGZVErWUd1rJ-YifRpfVLD-YaVt1_fTvHJWytRkZi-EsagdaniPVBlvmgGfMEeEwz4hgJmgWblBOjk8YAg_tmp_RD_vtDh4VSCwb1A2Ww=s16000&quot; title=&quot;solving equations&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;f(x) =&amp;nbsp;exp(x)+2^(-x) + 2*cos(x)-6 = 0&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# f() function which return value of given function.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# function given in question.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;exp&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;)+&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;**(-&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;) + &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;*&lt;span style=&quot;color: #dcdcaa;&quot;&gt;cos&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;)-&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;secent() function.&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# secent() function which takes 4 arguments&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# f = function, a and b interval, accuracy for accuracy of result&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# return solution to given function.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;secant&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;accuracy&lt;/span&gt;=-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1e-5&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if f(a)*f(b) &amp;gt;= 0 return None.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;)*&lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;) &amp;gt;= &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;None&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# set an = a.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# set bn = b.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;bn&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# index to count iterations.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# create lest of x variables to store answers for each iterations.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# which we use to find accuracy of 1e-5 or given.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; = [-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1e10&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;1e10&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# use while loop with this Condition&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# absolute differences of last two x value is greater or equal accuracy.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if not then while loop ends.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;abs&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;[-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]-&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;[-&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;]) &amp;gt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;accuracy&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# find xn value.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xn&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;bn&lt;/span&gt;-&lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt;) / (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;bn&lt;/span&gt;)-&lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt;))&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# find f value for xn.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;fxn&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xn&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if fan*fxn&amp;lt;0 set bn = xn.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt;)*&lt;span style=&quot;color: #9cdcfe;&quot;&gt;fxn&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;bn&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xn&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# elif fxn*fbn&amp;lt;0 set an = xn.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;elif&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;fxn&lt;/span&gt;*&lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;bn&lt;/span&gt;) &amp;lt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xn&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;bn&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;bn&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if fxn is 0 return xn.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;elif&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;fxn&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xn&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# else return None.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;None&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# xn append to x.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;append&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xn&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# increment i.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; += &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# return xn based on an and bn.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;bn&lt;/span&gt;-&lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt;) / (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;bn&lt;/span&gt;)-&lt;span style=&quot;color: #9cdcfe;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;an&lt;/span&gt;))&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Printing result:&lt;/h3&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# print solution.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;solving : exp(x)+2^(-x) + 2*cos(x)-6 = 0&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# find accuracy&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;accuracy&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;**(-&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# x value for fx = 0.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;secant&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;accuracy&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# find fx.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;fx&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;f&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;x = &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;lt;19}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;, with &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;lt;6}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;, givens f(x) = &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;lt;25}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;format&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;accuracy&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;fx&lt;/span&gt;))&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;Please check this tool created by me to convert the number base from 2 to 20 here:&amp;nbsp;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/number-converter-calculator.html&quot; target=&quot;_blank&quot;&gt;number base &lt;/a&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/number-converter-calculator.html&quot;&gt;converter&lt;/a&gt;&lt;/h3&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Output:&lt;/h3&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjnPDfuDHtG_5u2rJOF8MQRbPFUCMu6m1cN_kiM1gFmmsCbjnUB9cJYn-6Zuk_1_PK3CgfndjcX13mK-dqnRt0imx3IP3FlFSF6rrJXGIochjYBtRBIH__UdNSpMemcpWBSn-xjkqu4cDkE0uKpRdteKWkRKpXXrVehnIzQvRVm4xCA7TsgG0vsxDxv&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Secant Method Python With Desired Accuracy&quot; data-original-height=&quot;415&quot; data-original-width=&quot;648&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjnPDfuDHtG_5u2rJOF8MQRbPFUCMu6m1cN_kiM1gFmmsCbjnUB9cJYn-6Zuk_1_PK3CgfndjcX13mK-dqnRt0imx3IP3FlFSF6rrJXGIochjYBtRBIH__UdNSpMemcpWBSn-xjkqu4cDkE0uKpRdteKWkRKpXXrVehnIzQvRVm4xCA7TsgG0vsxDxv=s16000&quot; title=&quot;Secant Method Python With Desired Accuracy&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Image:&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiGm5BQEAEpWPa9scfWMOxVznFGD58K2rcRbaQRm9nNnLzZHjEFZAv6xsrCELaKt_VEel2eKNjyzGN1bupL6mIUigI_MCQcI9UShLf2F1NRkvqHtDIsgMEWA631HTk864jTy_u7BrfXTtl_ZZMG34eSfz6-szdSZUYbEvBrJgOYIcIB0yWDkh9w7aVI&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Secant Method Python With Desired Accuracy&quot; data-original-height=&quot;2732&quot; data-original-width=&quot;1400&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiGm5BQEAEpWPa9scfWMOxVznFGD58K2rcRbaQRm9nNnLzZHjEFZAv6xsrCELaKt_VEel2eKNjyzGN1bupL6mIUigI_MCQcI9UShLf2F1NRkvqHtDIsgMEWA631HTk864jTy_u7BrfXTtl_ZZMG34eSfz6-szdSZUYbEvBrJgOYIcIB0yWDkh9w7aVI=s16000&quot; title=&quot;Secant Method Python With Desired Accuracy&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Comment if you have any questions...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/6111277066415418017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/02/secant-method-python-with-desired-accuracy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/6111277066415418017'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/6111277066415418017'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/02/secant-method-python-with-desired-accuracy.html' title='Secant Method Python With Desired Accuracy'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEi-4Tm2SGI3ZnVj4T-0PtFBOQ9CitiDNHS89QB6PBo_DdYwWfxAczWE7Iwh5PpHP5t-pBQzm7oylfzYi3BGGZVErWUd1rJ-YifRpfVLD-YaVt1_fTvHJWytRkZi-EsagdaniPVBlvmgGfMEeEwz4hgJmgWblBOjk8YAg_tmp_RD_vtDh4VSCwb1A2Ww=s72-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-8345923688425077139</id><published>2022-01-13T15:05:00.004+05:30</published><updated>2023-01-29T00:52:39.975+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Hangman Game Using Python And C++</title><content type='html'>&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSOiy9R6BahOQWz_V5KmAuNPdjsH58Gk8yIEDh5tm9xiRKp2OSAv1S9yXAEstZ3P5YHZcfE8Pe8SYAAotP0Vgs0bi1sH9bImwz_gjunhJHjRjQ2ec-wYX1scZ9kuicZlaJKbAsG-Z-_KG9Tuvac27Jnkqq6fc7wpU548HZKZVWQTtBRs0Ma9YKw7lc/s1024/Hangman%20Game.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1024&quot; data-original-width=&quot;892&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSOiy9R6BahOQWz_V5KmAuNPdjsH58Gk8yIEDh5tm9xiRKp2OSAv1S9yXAEstZ3P5YHZcfE8Pe8SYAAotP0Vgs0bi1sH9bImwz_gjunhJHjRjQ2ec-wYX1scZ9kuicZlaJKbAsG-Z-_KG9Tuvac27Jnkqq6fc7wpU548HZKZVWQTtBRs0Ma9YKw7lc/w558-h640/Hangman%20Game.png&quot; width=&quot;558&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hangman word means man hanging on a string. and rules of games say that man has few numbers of lives to guess the correct word.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We have given any random word from the file of words which can be any hard or easy. if we guess the word in given lives then we saved man&#39;s life but if we fail to do so that man will die.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the next few minutes, you are going to know &lt;b&gt;what really is the hangman game? how to code it in cpp? how to code it in python?&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;What is hangman game:&amp;nbsp;&lt;/h2&gt;&lt;div style=&quot;text-align: left;&quot;&gt;We are given a sum n number of lives to save man&#39;s life which is currently hanging on a string through the head of the man.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;We will try to guess the letter of the word which is hidden for use if we guess wrong letter then given lives are decreased by one. if we fail to guess the whole word in the given number of total lives then our man going to die.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Hangman game in C++:&lt;/h2&gt;&lt;div&gt;We are going to implement a hangman game with 7 maximum wrong guesses. which means given lives are 7.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After 7 guesses goes wrong game was finessed and we lost the game. else if we guess the correct word we won the game.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Every time we will be getting a new random number from the file named &quot;words.txt&quot;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqab_Tl9D4XZucKSRQrvfkQeJD6fzCMnfUtOhWOtKxNHSruVJ6XR9s-C0tnVdwM1ZZpepZuUEwWHUNTmdv7lZJWpN4c7A4igEFOsHZzxcEHMrXsTkfJ2ozL3Vzv3Oxqqy65LjjxE1mGu4/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;words to guess&quot; data-original-height=&quot;295&quot; data-original-width=&quot;331&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqab_Tl9D4XZucKSRQrvfkQeJD6fzCMnfUtOhWOtKxNHSruVJ6XR9s-C0tnVdwM1ZZpepZuUEwWHUNTmdv7lZJWpN4c7A4igEFOsHZzxcEHMrXsTkfJ2ozL3Vzv3Oxqqy65LjjxE1mGu4/s16000/image.png&quot; title=&quot;words to guess&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First of all import one header file&amp;nbsp;&lt;b&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;We will use this function random_word() to get the random word. see the implementation of code this will give us the equal probability of getting random word:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// this function returns random word by reading words_1.txt file.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;random_word&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // open file words.txt in input file stream point.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ifstream&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;open&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;words.txt&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // create set of word.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;set&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words_set&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;words&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words_set&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // convert set to vector.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words_array&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;auto&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;word&lt;/span&gt; : &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words_set&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;word&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // array size.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // set seed to time(0)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;srand&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;time&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;));&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // random integer in range 0 to n-1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;random_int&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;rand&lt;/span&gt;() % &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // close words file.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;close&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // return random_word[random_int].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;words_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;random_int&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Our next function will be to print the status of the game if the letter guessed is&amp;nbsp; wrong see this statues printing code below:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// print_status(guesses_done) function print status of game.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print_status&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+-------&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+----+&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+-------&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+----+&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+-------&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+----+&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;o&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+-------&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+----+&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;o&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+-------&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+----+&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;o&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+-------&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+----+&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;o&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;|/&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+-------&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+----+&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;o&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;|/&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; /&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+-------&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; &amp;gt;= &lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+----+&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;o&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;|/&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; &amp;nbsp;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;| &amp;nbsp; / &lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;|&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;+-------&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
  &lt;div&gt;
  &lt;span style=&quot;font-size: medium;&quot;&gt;
  &lt;script async=&quot;&quot; crossorigin=&quot;anonymous&quot; src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1832089766452330&quot;&gt;&lt;/script&gt;
&lt;ins class=&quot;adsbygoogle&quot; data-ad-client=&quot;ca-pub-1832089766452330&quot; data-ad-format=&quot;fluid&quot; data-ad-layout=&quot;in-article&quot; data-ad-slot=&quot;5547237930&quot; style=&quot;display: block; text-align: center;&quot;&gt;&lt;/ins&gt;
&lt;script&gt;
     (adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;We want our program to give feedback to enter letters again if the user inputs the wrong letter or non-letter input for that we create a get letter function to get always a letter from the user. this function recursively returns letters.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// get_letter() which return a letter entered by user.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_letter&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // asking for input.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter the alphabet:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // if length of L is 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;L&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;L&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;L&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;() == &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // return L.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // else ask to try again.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;please try again to input&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // and recursively return call of get_letter() function.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_letter&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now our main game() function goes here:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In starting of the main function create variables that are needed and call the functions which we have created above when they are needed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;While loop to check guess done is less than max guesses.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If the guess is correct then update guessed word and non-guessed word accordingly.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// game() function which starts game.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;game&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // guesses allocated 7.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // set guesses_done = 0 to count wrong guesses.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // get hidden_word;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;hidden_word&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;random_word&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // length of hidden_word.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n_length&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;hidden_word&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // guessed word which tracks guessed letter recode.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n_length&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;*&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // notguessed word which tracks letter recode which are not guessed.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessing_word&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;hidden_word&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // printing total number of guesses use has and length of hidden word.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Guess the &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n_length&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; letter word &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;, You have &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; guesses.&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // store guessed letter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;set&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_letter&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // print starting status.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print_status&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt;);&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // run while loop for guesses_done &amp;lt; max_guesses&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // use get_letter() function to get always letter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_letter&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // store copy of guess.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;copy_guess&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // find index of letter form notguessed_word list.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_l&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // checking if letter is found in uppercase or lowercase.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;tolower&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_l&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessing_word&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;find&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_l&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessing_word&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;npos&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;toupper&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_l&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessing_word&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;find&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_l&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessing_word&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;npos&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;copy_guess&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if guess letter found in notguessing_word.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_l&lt;/span&gt; != &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessing_word&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;npos&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n_length&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessing_word&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set guessed_word index_l th element equal to &amp;nbsp;guess letter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // erase letter form notguessed_word by using &#39;*&#39; character.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessing_word&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;*&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // print msg of correct guess.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Correct guess &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if it is from previously guessed letter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_letter&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;find&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;) &lt;span style=&quot;color: #dcdcaa;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_letter&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;end&lt;/span&gt;())&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;letter had been tried before so, not counted as guess.&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // print Incorrect msg.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Incorrect letter.&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // count Incorrect guess&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // print status&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print_status&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // insert upper and lower of guess letter to guessed_letter&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_letter&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;tolower&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_letter&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;insert&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;toupper&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // print total remaining guesses.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; You have &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; guesses.&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // check if word is complated or not&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if &#39;*&#39; not in guessed_word then guessing is complated.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;find&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;*&#39;&lt;/span&gt;) == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;npos&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // print won msg.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Yes!!! The correct word is &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;! you won the game.&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // ask to play again.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Do you want to start a new game?(Yes/No):&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;transform&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;(), &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;end&lt;/span&gt;(), &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;(), ::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;tolower&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;yes&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Game is restarted....&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if input is yes call recursively game() to restart game.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;game&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // else if guesses_done become max_guesses.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; &amp;gt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // print status.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print_status&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // print loss msg.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;No!!! The correct word is &quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;hidden_word&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;! you loss the game.&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // ask to play again.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Do you want to start a new game?(Yes/No):&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;transform&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;(), &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;end&lt;/span&gt;(), &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;begin&lt;/span&gt;(), ::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;tolower&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;yes&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Game is restarted....&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if input is yes call recursively game() to restart game.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;game&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;Call game function from the main function.&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// starting point.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;game&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Output of&amp;nbsp; C++ program hangman game:&lt;/h3&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJA3a3idBhDi_-iDeCiFgV3qo3iWei9wK4p59Zll683HRTxeY-0dV_ak94gIa3D9lC3O0lHoiGXoO7SyoiSxFfj0l-XMUV_yx-z8c_6X0wys-6xSOLGYzZ35VoSva2sEXtwTgEEF6yBcU/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;The output of the program game&quot; data-original-height=&quot;535&quot; data-original-width=&quot;518&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJA3a3idBhDi_-iDeCiFgV3qo3iWei9wK4p59Zll683HRTxeY-0dV_ak94gIa3D9lC3O0lHoiGXoO7SyoiSxFfj0l-XMUV_yx-z8c_6X0wys-6xSOLGYzZ35VoSva2sEXtwTgEEF6yBcU/s16000/image.png&quot; title=&quot;The output of the program game&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio4n5Y5qppnKo_tEhXd3sTJWoDBGEYh9gx1iKYlX6Hv5j1GtmRH8_khsCunLdWgjrqU4c6q_GtP7rGd0DsxfbuBcnAgILz9gNQfEaJWMmzy5jx3zVxOO8yA00RFAwKHXNF3aIXqqL6C90/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;The output of the program game&quot; data-original-height=&quot;306&quot; data-original-width=&quot;526&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio4n5Y5qppnKo_tEhXd3sTJWoDBGEYh9gx1iKYlX6Hv5j1GtmRH8_khsCunLdWgjrqU4c6q_GtP7rGd0DsxfbuBcnAgILz9gNQfEaJWMmzy5jx3zVxOO8yA00RFAwKHXNF3aIXqqL6C90/s16000/image.png&quot; title=&quot;The output of the program game&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;Python program with a different example&lt;/h2&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;random&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# get_letter() function which always return a letter (string of 1 length).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_letter&lt;/span&gt;():&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# asking for input.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;L&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter the alphabet:&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if length of L is 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(&lt;span style=&quot;color: #4fc1ff;&quot;&gt;L&lt;/span&gt;) == &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# return L.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;L&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# else ask to try again.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;please try again to input&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# and recursively return call of get_letter() function.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_letter&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# return string of status of hangman.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;display_hangman&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;attempts&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;stages&lt;/span&gt; = [&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;O&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;|/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; / &lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&quot;&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;O&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;|/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&quot;&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;O&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\\&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&quot;&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;O&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&quot;&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;O&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&quot;&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;stages&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;attempts&lt;/span&gt;])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# game() function.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;game&lt;/span&gt;():&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# create empty dictionary.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;dict&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Animals&#39;&lt;/span&gt;] = [&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;dolphin&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;shark&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;coyote&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;hippopotamus&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;elephant&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;rhinoceros&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;squid&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;cardinal&#39;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;wolverine&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;alpaca&#39;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Food&#39;&lt;/span&gt;] = [&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;spaghetti&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;pizza&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;burrito&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;sushi&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;taco&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;cheeseburger&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;bratwurst&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;guacamole&#39;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;cheesecake&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;cheesesteak&#39;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Brands&#39;&lt;/span&gt;] = [&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;mcdonalds&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;chevrolet&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;mercedes&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;amazon&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;google&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;delta&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;microsoft&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;disney&#39;&lt;/span&gt;,&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;boeing&#39;&lt;/span&gt;, &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;comcast&#39;&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# asking to Choose category.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;category&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Choose a category: Animals, Food, Brands: &#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# asking to choose a level&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;level&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Choose a category: first, second, three: &quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length_by_level&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if level is first add 5 to length_by_level&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;level&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;first&quot;&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length_by_level&lt;/span&gt; += &lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# else if level is second add 9 to length_by_level&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;elif&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;level&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;second&quot;&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length_by_level&lt;/span&gt; += &lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# else add 20 to length_by_level&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length_by_level&lt;/span&gt; += &lt;span style=&quot;color: #b5cea8;&quot;&gt;20&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# filter string by length.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;category&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Food&#39;&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;original_word&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;random&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;choice&lt;/span&gt;(&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;list&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;filter&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;lambda&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;: &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;__len__&lt;/span&gt;() &amp;lt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length_by_level&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Food&#39;&lt;/span&gt;])))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;elif&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;category&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Animals&#39;&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;original_word&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;random&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;choice&lt;/span&gt;(&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;list&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;filter&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;lambda&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;: &lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;) &amp;lt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length_by_level&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Animals&#39;&lt;/span&gt;])))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;elif&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;category&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Brands&#39;&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;original_word&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;random&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;choice&lt;/span&gt;(&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;list&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;filter&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;lambda&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;: &lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;) &amp;lt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;length_by_level&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;[&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;Brands&#39;&lt;/span&gt;])))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Invalid category choice&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;quit&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# welcome_message&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;The Hangman Game&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# copy of hidden_word.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;hidden_word&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;original_word&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# length of hidden_word&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n_length&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;hidden_word&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# guesses allocated 5.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# guessed word which tracks guessed letter recode.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;list&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;-&#39;&lt;/span&gt;*&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n_length&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# notguessed word which tracks letter recode which are not guessed.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessed_word&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;list&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;hidden_word&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# printing total number of guesses use has and length of hidden word.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Guess the &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n_length&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt; letter word &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&#39;&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;join&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt;)&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;, You have &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt; guesses.&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# printing hangman here list of string in display_hangman is in reverse order so i have printed it reversely by passing negative index to print appropriately.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;display_hangman&lt;/span&gt;(-&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt;-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;))&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# run while loop for guesses_done &amp;lt; max_guesses&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# use get_letter() function to get always letter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;get_letter&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if guess is from notguessed_word letter. do this&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessed_word&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# find index of letter form notguessed_word list.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_l&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessed_word&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;index&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# set guessed_word index_l th element equal to &amp;nbsp;guess letter.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_l&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guess&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# erase letter form notguessed_word by using &#39;-&#39; character.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;notguessed_word&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;index_l&lt;/span&gt;] = &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;-&#39;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# print msg of correct guess.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Correct guess &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&#39;&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;join&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt;)&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# else print msg of Incorrect guess.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Incorrect letter.&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# count Incorrect guess&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; += &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;display_hangman&lt;/span&gt;(-&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt;-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;))&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# print total remaining guesses.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; You have &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt; guesses.&quot;&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# check if word is complated or not&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if &#39;-&#39; not in guessed_word then guessing is complated.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;-&#39;&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;not&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;guessed_word&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# print won msg.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Yes!!! The correct word is &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;hidden_word&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;! you won the game.&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# ask to play again.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Do you want to start a new game?(Yes/No):&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;lower&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;yes&#39;&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Game is restarted....&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if input is yes call recursively game() to restart game.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;game&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# else if guesses_done become max_guesses.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;elif&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;guesses_done&lt;/span&gt; &amp;gt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;max_guesses&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# printing last stage of hangman.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;display_hangman&lt;/span&gt;(-&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# print loss msg.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;No!!! The correct word is &lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&#39;&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;join&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;hidden_word&lt;/span&gt;)&lt;span style=&quot;color: #569cd6;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;! you loss the game.&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# ask to play again.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Do you want to start a new game?(Yes/No):&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;lower&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;new_game&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;yes&#39;&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Game is restarted....&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if input is yes call recursively game() to restart game.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;game&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;break&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# thanks to user.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Thank you for playing Hangman!&quot;&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;__name__&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;__main__&#39;&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;game&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Output of&amp;nbsp; Python program hangman game:&lt;/h3&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKf6JKCJ5A1ds5XTjsHxAKLYLJuMiYDZ0uihq38qbe3O8U7vHLAlKyqAW1N2jnJh3ZZfhaRKTFQ-BWxkweS0cQNgdek-RqCnMkNJX9aI8ypD3AZTQ3j0T5XkQUlkVME4ncDKEp22sQaPA/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Output of  Python program hangman game&quot; data-original-height=&quot;429&quot; data-original-width=&quot;630&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKf6JKCJ5A1ds5XTjsHxAKLYLJuMiYDZ0uihq38qbe3O8U7vHLAlKyqAW1N2jnJh3ZZfhaRKTFQ-BWxkweS0cQNgdek-RqCnMkNJX9aI8ypD3AZTQ3j0T5XkQUlkVME4ncDKEp22sQaPA/s16000/image.png&quot; title=&quot;Output of  Python program hangman game&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_HorWCD4DFPE6jLj7104BVT3YuzIM2pUPEUbJa1P-w47MSkMLrvntZzNocJkro1rBOWmgT06QTx6UP6qWs11NrGJD_3jSyxwh8yI4gd1wJgNvhuu2duUXJLeoYj1BEqOJl58uK-nUXjg/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Output of  Python program hangman game&quot; data-original-height=&quot;366&quot; data-original-width=&quot;532&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_HorWCD4DFPE6jLj7104BVT3YuzIM2pUPEUbJa1P-w47MSkMLrvntZzNocJkro1rBOWmgT06QTx6UP6qWs11NrGJD_3jSyxwh8yI4gd1wJgNvhuu2duUXJLeoYj1BEqOJl58uK-nUXjg/s16000/image.png&quot; title=&quot;Output of  Python program hangman game&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Read also:&lt;/h2&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/prove-numpy-is-faster-than-normal-list.html&quot; target=&quot;_blank&quot;&gt;Prove Numpy Is Faster Than Normal List (python)&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/find-type-of-quadrilateral-with-given-points.html&quot; target=&quot;_blank&quot;&gt;Find the type of Quadrilateral with given 4 points of the quadrilateral in cpp and python.&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;C++ code image:&lt;/h2&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT3tz_yLOhZztCxTIt6JwYKGAoY-VUZ9Jug5yS-LwsHsZVRRqKks9z1KWAuSut9beSuJvIyy-wRJb3OkExT8UJ3IEVEpthCUfjU53eWJA6zveyzduerR_EpT5Zfkf1jLe7fHry20op6lM/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Cpp code image hangman&quot; data-original-height=&quot;6266&quot; data-original-width=&quot;1170&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT3tz_yLOhZztCxTIt6JwYKGAoY-VUZ9Jug5yS-LwsHsZVRRqKks9z1KWAuSut9beSuJvIyy-wRJb3OkExT8UJ3IEVEpthCUfjU53eWJA6zveyzduerR_EpT5Zfkf1jLe7fHry20op6lM/s16000/image.png&quot; title=&quot;Cpp code image hangman&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiDOvojXc4LJsX4ph_P-CiqhGI00ymaN05rcJ8u_2z9gRfYfzx_wTRw0rHSBoTBtNvEU7TBS7L3mrPR5SxX7D5-Vz5qBW7nkNpNIfNUrcNEtlYWaZQGH4YETKjTSGUBbIAjfdRIDnq730/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Cpp code image hangman&quot; data-original-height=&quot;5810&quot; data-original-width=&quot;2126&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiDOvojXc4LJsX4ph_P-CiqhGI00ymaN05rcJ8u_2z9gRfYfzx_wTRw0rHSBoTBtNvEU7TBS7L3mrPR5SxX7D5-Vz5qBW7nkNpNIfNUrcNEtlYWaZQGH4YETKjTSGUBbIAjfdRIDnq730/s16000/image.png&quot; title=&quot;Cpp code image hangman&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Python code image:&lt;/h2&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkjR15FG4ZnUjiZBKigQboK1AXh7reavlp_RgROzCvyD1CVgN65Ys1f67CtB0lC7Fisd7hTHRpZdQrPFtk7xsFEj9v3oCaJi8SIBsVLefl2ACgnfweWo3A-lAbhCNilkJcYKfWm-wTRcY/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Python code image hangman game&quot; data-original-height=&quot;7748&quot; data-original-width=&quot;2664&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkjR15FG4ZnUjiZBKigQboK1AXh7reavlp_RgROzCvyD1CVgN65Ys1f67CtB0lC7Fisd7hTHRpZdQrPFtk7xsFEj9v3oCaJi8SIBsVLefl2ACgnfweWo3A-lAbhCNilkJcYKfWm-wTRcY/s16000/image.png&quot; title=&quot;Python code image hangman game&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/8345923688425077139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/01/hangman-game-using-python-and-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8345923688425077139'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8345923688425077139'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/01/hangman-game-using-python-and-c.html' title='Hangman Game Using Python And C++'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSOiy9R6BahOQWz_V5KmAuNPdjsH58Gk8yIEDh5tm9xiRKp2OSAv1S9yXAEstZ3P5YHZcfE8Pe8SYAAotP0Vgs0bi1sH9bImwz_gjunhJHjRjQ2ec-wYX1scZ9kuicZlaJKbAsG-Z-_KG9Tuvac27Jnkqq6fc7wpU548HZKZVWQTtBRs0Ma9YKw7lc/s72-w558-h640-c/Hangman%20Game.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-30.020143171244658 8.6503799999999984 71.207511171244661 149.27537999999998</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-590635199818946107</id><published>2022-01-10T19:03:00.013+05:30</published><updated>2023-06-28T12:23:08.189+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="numpy"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Prove Numpy Is Faster Than Normal List (python)</title><content type='html'>
&lt;h2 style=&quot;text-align: left;&quot;&gt;Introduction:&lt;/h2&gt;&lt;div&gt;We know numpy is the fast and efficient library to process numeric data that we study in every course of python or data science and on the internet &lt;b&gt;but we don&#39;t know how fast numpy really is.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But today&amp;nbsp; I will show you &lt;b&gt;how fast numpy is?&lt;/b&gt; and &lt;b&gt;why is that fast over normal python?&lt;/b&gt; with an &lt;b&gt;example&lt;/b&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the next few minutes, you are going to know &lt;b&gt;what is numpy? why is numpy faster than normal python? python array vs numpy array. proof of numpy fastness.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;What is numpy:&amp;nbsp;&lt;/h2&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Numpy open-source python library with the additional support of large, multi-dimensional arrays, matrices, and enrich collections of math operations and array operations.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Using numpy we can achieve c nad c++ like the speed of array processing in python that is not possible without numpy.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Numpy is used to perform wide range of operations on large numerical array in efficient way. and I will prove that in the next section.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Why is numpy faster than python list and how numpy different from python list?&lt;/h2&gt;&lt;div&gt;In numpy when we create the numpy array then numpy will allocate contiguous memory block of the array which is different from the python list structure. In python list, it is linked list like structure of small memory blocks each of that can store the only unit amount of data on it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Numpy array structure is the sequence of memory locations in the disk and python list is collection of the clustered memory locations in the disk.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Memory access in numpy is faster due to the contiguous block of the memory location. Reading and writing of data in memory become easy and fast in numpy arrays. But in the case of numpy list, all memory blocks (segments) are scattered in memory so accessing a particular memory location is hard and slow in python list.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Python list is flexible and numpy array is fast.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Numpy is so fast because it uses a highly optimized library for matrix operations called the BLAS library. This library is written in Fortran and is used in many scientific computing packages. BLAS stands for Basic Linear Algebra Subprograms and is used to perform basic linear algebra operations like matrix multiplication, addition, and subtraction. Additionally, numpy makes use of vectorization and other optimizations that reduce the amount of code needed to perform operations on matrices, drastically reducing the amount of time needed to perform calculations.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp-ZCjvwx-wdAqLeQE0IpNswLaCYORsB1OPF9tzyWg9TwUsMQXUoLOaLshedNtIYfWpZQxDDJIw43JX8g5l_Phrqmkny34DEVB2-c-zbGuSD_0atHIr2tmG4zDFS0wo26YSpw7kAB76wo/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;speed of time numpy&quot; data-original-height=&quot;281&quot; data-original-width=&quot;500&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp-ZCjvwx-wdAqLeQE0IpNswLaCYORsB1OPF9tzyWg9TwUsMQXUoLOaLshedNtIYfWpZQxDDJIw43JX8g5l_Phrqmkny34DEVB2-c-zbGuSD_0atHIr2tmG4zDFS0wo26YSpw7kAB76wo/w640-h360/image.png&quot; title=&quot;speed of time numpy&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: 24px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: 24px;&quot;&gt;proof of numpy fastness:&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Example:&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;I have created two functions with the same input and same output but different implementations.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;If our input is&lt;b&gt; n = 6 &lt;/b&gt;then the output will be:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBR61LY6ehUqbNFIzRd8b0CStscxsTdEFaOwBYD1kHCG3Wej4_U3ZXHe0MdBdCaO7grVptJxss8Gz7FeqFxQBbxLRLkONvGAeEy6XNKLnUDPR__vj6O_JoDjKXzxOOQLFM46Yg0tbm9dE/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;input is n = 6 then the output&quot; data-original-height=&quot;150&quot; data-original-width=&quot;306&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBR61LY6ehUqbNFIzRd8b0CStscxsTdEFaOwBYD1kHCG3Wej4_U3ZXHe0MdBdCaO7grVptJxss8Gz7FeqFxQBbxLRLkONvGAeEy6XNKLnUDPR__vj6O_JoDjKXzxOOQLFM46Yg0tbm9dE/s16000/image.png&quot; title=&quot;input is n = 6 then the output&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;for&lt;b&gt; n = 8 &lt;/b&gt;output will be:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjZO8YM1oUG0JAxElt6c3tVO6B9DbIsycrkP-tATk3JKhCSy4AfoPY8fDGyh17S2OyBehDLKhvp9PQDoRLP7AexP4LlLx5OwWpni3yyNNw5iYioqjRUnMbCAw1YWzKBzb5Jo90-fdyKVY/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;n = 8 output&quot; data-original-height=&quot;180&quot; data-original-width=&quot;376&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjZO8YM1oUG0JAxElt6c3tVO6B9DbIsycrkP-tATk3JKhCSy4AfoPY8fDGyh17S2OyBehDLKhvp9PQDoRLP7AexP4LlLx5OwWpni3yyNNw5iYioqjRUnMbCAw1YWzKBzb5Jo90-fdyKVY/s16000/image.png&quot; title=&quot;n = 8 output&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;In short, we are creating a pascal triangle inside the two-dimensional array of size &lt;b&gt;n x n.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Both functions take n number as an argument and return a numpy array of size&lt;b&gt; n x n.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span&gt;Importing needed libraries:&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# import numpy and time .&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;import&lt;/span&gt; numpy &lt;span style=&quot;color: #c586c0;&quot;&gt;as&lt;/span&gt; np&lt;/div&gt;&lt;div style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;import&lt;/span&gt; time&lt;/div&gt;&lt;div style=&quot;font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;import&lt;/span&gt; matplotlib.pyplot &lt;span style=&quot;color: #c586c0;&quot;&gt;as&lt;/span&gt; plt&lt;/div&gt;&lt;div style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;function1:&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;We will be going to implement an addition operation using for loop on created numpy array of size&lt;b&gt; n x n.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;function1:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# function1() which return numpy array of n x n size filled with pascal triangle.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# using two for loop&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;function1&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# create array of size n x n filled with 0.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; arr = np.zeros((n, n),&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dtype&lt;/span&gt;=np.int32)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# iterate i using &amp;nbsp;for loop from 1 to n-1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,n):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# set first element to i.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arr[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;] = i&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# iterate using j for loop from 1 to n-1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; j &lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,n):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# fill arr[i][j] with value of arr[i-1][j-1] + arr[i-1][j]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arr[i][j] = arr[i-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;] + arr[i-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# return array.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; arr&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;function2:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;We will be going to implement an addition operation using numpy array addition on created numpy array of size &lt;b&gt;n x n.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;function2:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# function2() which return numpy array of n x n size filled with pascal triangle.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# using one for loop with numpy vectorization&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;function2&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# create array of size n x n filled with 0.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; arr = np.zeros((n, n),&lt;span style=&quot;color: #9cdcfe;&quot;&gt;dtype&lt;/span&gt;=np.int32)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# iterate i using for loop from 1 to n-1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;, n):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# set first element to i.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arr[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;] = i&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# create addition array with addition of every arr[i-1][j-1] with arr[i-1][j]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; addition = arr[i-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:n-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]+arr[i-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;:n]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# add 0 to first index to reach size of n.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; addition = np.insert(addition, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# add it to arr[i].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arr[i] = arr[i] + addition&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# return array.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; arr&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Testing of function1 and function2:&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO3I2nRbWi98xpvOOYzLC8nt96VOuuxMx8KXpxr90cO8QnvmsNxyLDVvecVNkPiZZ30uujJCNDx606veymJ5UraqDd8LHtc3vUEH8AJkGgWS4zHPz1E4hpjZ9KnDGS1NIPkwj4Rrz2mRc/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Testing of function1 and function2&quot; data-original-height=&quot;539&quot; data-original-width=&quot;440&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO3I2nRbWi98xpvOOYzLC8nt96VOuuxMx8KXpxr90cO8QnvmsNxyLDVvecVNkPiZZ30uujJCNDx606veymJ5UraqDd8LHtc3vUEH8AJkGgWS4zHPz1E4hpjZ9KnDGS1NIPkwj4Rrz2mRc/s16000/image.png&quot; title=&quot;Testing of function1 and function2&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Counting time:&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;Now, we are going to count time required for specific input not for&lt;b&gt; n = 6&lt;/b&gt; not for&lt;b&gt; n = 8 &lt;/b&gt;but for n from&amp;nbsp;&lt;b&gt;[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096].&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;These are numbers that can be generated by simply placing 2&#39;s power 0 to 12.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;we will count time using the start time and end time as before and after calling functions and with different of them we will find the required time.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For function1:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# list to store execution time.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;function1_execution_time = []&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# N size.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Ni = &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;13&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# start time.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; start_time = time.time()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# calling function1()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; function1(Ni)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# end time.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; end_time = time.time()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# append difference.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; function1_execution_time.append(end_time - start_time)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# multiply Ni by 2.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; Ni*=&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div&gt;function1_execution_time&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Output for function1:&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9KKGu_PZjpvx-hF5vPr4JciwpwMU7N31Zj8kh51DRv1KJHtEia5oDJSz61K9kOE5wMlvU-3saM11EJac6pskLxDGvhwpF1aL4EddOBLM1_sqgO2XK5Blweapb7hfLqEzY1xRYv9VeTXA/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Output for function1&quot; data-original-height=&quot;304&quot; data-original-width=&quot;232&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9KKGu_PZjpvx-hF5vPr4JciwpwMU7N31Zj8kh51DRv1KJHtEia5oDJSz61K9kOE5wMlvU-3saM11EJac6pskLxDGvhwpF1aL4EddOBLM1_sqgO2XK5Blweapb7hfLqEzY1xRYv9VeTXA/s16000/image.png&quot; title=&quot;Output for function1&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;For function2:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# same as above.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;function2_execution_time = []&lt;/div&gt;&lt;div&gt;Ni = &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;13&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; start_time = time.time()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# calling function2()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; function2(Ni)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; end_time = time.time()&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; function2_execution_time.append(end_time - start_time)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; Ni*=&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;function2_execution_time&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Output for function2:&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9KKGu_PZjpvx-hF5vPr4JciwpwMU7N31Zj8kh51DRv1KJHtEia5oDJSz61K9kOE5wMlvU-3saM11EJac6pskLxDGvhwpF1aL4EddOBLM1_sqgO2XK5Blweapb7hfLqEzY1xRYv9VeTXA/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9KKGu_PZjpvx-hF5vPr4JciwpwMU7N31Zj8kh51DRv1KJHtEia5oDJSz61K9kOE5wMlvU-3saM11EJac6pskLxDGvhwpF1aL4EddOBLM1_sqgO2XK5Blweapb7hfLqEzY1xRYv9VeTXA/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt3h4Nlx1CwCPHVVYxDgc5BZYjFWVSIwJNRZeY4clBzgWKiijLerkUGic963rw57b6a63tB-bQ-7vBZDnzJt5E16DlDEDkZM66JGbcQl11YYHjFw-JNQUOwzECC-4iKiGCLiAtHv71X0c/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Output for function2&quot; data-original-height=&quot;302&quot; data-original-width=&quot;197&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt3h4Nlx1CwCPHVVYxDgc5BZYjFWVSIwJNRZeY4clBzgWKiijLerkUGic963rw57b6a63tB-bQ-7vBZDnzJt5E16DlDEDkZM66JGbcQl11YYHjFw-JNQUOwzECC-4iKiGCLiAtHv71X0c/s16000/image.png&quot; title=&quot;Output for function2&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;We can see from the above two outputs that function1 time is increasing exponentially with inputs power of 2 as compared to function2.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Plotting:&lt;/h3&gt;&lt;div&gt;The latest plot is the graph of the time required for one call vs input power of 2.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# ploting.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;plt.figure(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;figsize&lt;/span&gt;=(&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# first line for function1.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;plt.plot(x,function1_execution_time,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;normal for loop&quot;&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;marker&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;o&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# second line for function2.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;plt.plot(x,function2_execution_time,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;numpy array operation&quot;&lt;/span&gt;,&lt;span style=&quot;color: #9cdcfe;&quot;&gt;marker&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;o&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# seting label and title&lt;/span&gt;&lt;/div&gt;&lt;div&gt;plt.xlabel(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;array size N&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;plt.ylabel(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;execution time in second&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;plt.title(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Execution time for two function which does same thing in different ways.&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# set x ticks to x array(size of input.).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;plt.xticks(x)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;# show legend and plot.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;plt.legend()&lt;/div&gt;&lt;div&gt;plt.show()&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/h4&gt;&lt;div&gt;&lt;script async=&quot;&quot; crossorigin=&quot;anonymous&quot; src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1832089766452330&quot;&gt;&lt;/script&gt;
&lt;ins class=&quot;adsbygoogle&quot; data-ad-client=&quot;ca-pub-1832089766452330&quot; data-ad-format=&quot;fluid&quot; data-ad-layout=&quot;in-article&quot; data-ad-slot=&quot;5547237930&quot; style=&quot;display: block; text-align: center;&quot;&gt;&lt;/ins&gt;
&lt;script&gt;
     (adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;Output:&lt;/h4&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjFYgZdQnK5VbXAKueNnluS4oxDNA6mhi25TXjqjkZ6h_8-2w3sTJ0q64K88yIoyO5m1h1ppphTCbTiIBmCBtOIXwPTw07lrkH_oZuMeE64E57jjsdbKfnKPHwZhxFGbQoE6WBYt9A-789uKMvJVLSBF5xSb1qzjI1TVlpQNRcR_FLxni1GKE1Sp4nf=s940&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;graph of the time required for one call vs input power of 2&quot; border=&quot;0&quot; data-original-height=&quot;550&quot; data-original-width=&quot;940&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjFYgZdQnK5VbXAKueNnluS4oxDNA6mhi25TXjqjkZ6h_8-2w3sTJ0q64K88yIoyO5m1h1ppphTCbTiIBmCBtOIXwPTw07lrkH_oZuMeE64E57jjsdbKfnKPHwZhxFGbQoE6WBYt9A-789uKMvJVLSBF5xSb1qzjI1TVlpQNRcR_FLxni1GKE1Sp4nf=s16000&quot; title=&quot;graph of the time required for one call vs input power of 2&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Conclusion:&lt;/h2&gt;&lt;div&gt;With the numpy, we can achieve efficiency and code simplicity in over-program or software. And we can perform large size of array operations efficiently.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Read more:&lt;/h2&gt;&lt;div&gt;&lt;div&gt;Please check this tool created by me to convert the number base from 2 to 20 here:&amp;nbsp;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/number-converter-calculator.html&quot; target=&quot;_blank&quot;&gt;number base converter&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/hangman-game-using-python-and-c.html&quot; target=&quot;_blank&quot;&gt;Hangman game in cpp and python&lt;/a&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;Complete code:&lt;/h2&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhup8C00IfmGUxM0psy-frkUu7ljeAnm6dLuBHKZWmowHoPBOL7TZtBe4F4ohpccmrn_HBp5b-xuqoBzlIjeOM1s8BgdrTY5f2q80zayc6pDE9R2TJbyA9tJm7s1eG29IPrvPlvci50ya8/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;code of Prove Numpy Is Faster Than Normal List&quot; data-original-height=&quot;870&quot; data-original-width=&quot;1400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhup8C00IfmGUxM0psy-frkUu7ljeAnm6dLuBHKZWmowHoPBOL7TZtBe4F4ohpccmrn_HBp5b-xuqoBzlIjeOM1s8BgdrTY5f2q80zayc6pDE9R2TJbyA9tJm7s1eG29IPrvPlvci50ya8/s16000/image.png&quot; title=&quot;code of Prove Numpy Is Faster Than Normal List&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgieXn3P_p8zEQCXY59iZIvXn9EAmihMXSzBKbGPxDKA90kE1ySp6HxmtliW8VAdBenqrtzUSl3jJplUFJAU8KYTwhT-klOOaLFc-Gz5krYoMFKqdWtoHioO1TmOIUB3CtgBg4TcnaZjXs/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;code of Prove Numpy Is Faster Than Normal List&quot; data-original-height=&quot;794&quot; data-original-width=&quot;1462&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgieXn3P_p8zEQCXY59iZIvXn9EAmihMXSzBKbGPxDKA90kE1ySp6HxmtliW8VAdBenqrtzUSl3jJplUFJAU8KYTwhT-klOOaLFc-Gz5krYoMFKqdWtoHioO1TmOIUB3CtgBg4TcnaZjXs/s16000/image.png&quot; title=&quot;code of Prove Numpy Is Faster Than Normal List&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj11qSLn_7lW1tpM3_XKchvieFo9SGKj_Jog0-ZiEE5Umbg-1mDMx7X5s8G78gccxVu7jpHsBoJi4JUi-V7cFPbKfjTTsxRRF5KO0_Bg8Yxcm-2lzFOms6e-yHwciJK6OXVm_wNUo6B-tI/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;code of Prove Numpy Is Faster Than Normal List&quot; data-original-height=&quot;148&quot; data-original-width=&quot;696&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj11qSLn_7lW1tpM3_XKchvieFo9SGKj_Jog0-ZiEE5Umbg-1mDMx7X5s8G78gccxVu7jpHsBoJi4JUi-V7cFPbKfjTTsxRRF5KO0_Bg8Yxcm-2lzFOms6e-yHwciJK6OXVm_wNUo6B-tI/s16000/image.png&quot; title=&quot;code of Prove Numpy Is Faster Than Normal List&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd7ilHN6coTg4tysD_cVCHZGSwgT519MhQ5CntFCssNlkbM4Q77YUJKyFpgEexRmngzhG-LK4Vs-a7mCRJ0EpG7xU16GungnabF49w5Td24_5UB0itVK5NgBZhKrYtslgrjLVk8K3Ls5s/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;code of Prove Numpy Is Faster Than Normal List&quot; data-original-height=&quot;148&quot; data-original-width=&quot;696&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd7ilHN6coTg4tysD_cVCHZGSwgT519MhQ5CntFCssNlkbM4Q77YUJKyFpgEexRmngzhG-LK4Vs-a7mCRJ0EpG7xU16GungnabF49w5Td24_5UB0itVK5NgBZhKrYtslgrjLVk8K3Ls5s/s16000/image.png&quot; title=&quot;code of Prove Numpy Is Faster Than Normal List&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtFMTkZIyvUHZmwofTimv38_bpCz2QhInosGOFq0xWo3MmBPBUCyYVzq2m3pt3O2KvDYezjakT5rm6gvQphJDQ5VLbeV62w6esoAETWSw-n1iAS_5yilnth5htMkLwROdpp1iXd7XpRqA/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;code of Prove Numpy Is Faster Than Normal List&quot; data-original-height=&quot;718&quot; data-original-width=&quot;1046&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtFMTkZIyvUHZmwofTimv38_bpCz2QhInosGOFq0xWo3MmBPBUCyYVzq2m3pt3O2KvDYezjakT5rm6gvQphJDQ5VLbeV62w6esoAETWSw-n1iAS_5yilnth5htMkLwROdpp1iXd7XpRqA/s16000/image.png&quot; title=&quot;code of Prove Numpy Is Faster Than Normal List&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaEmN4Hzz9qwl0lI5S0jERx5a4bSw7yzDots6BfISftemALQ6jMcIse8rftxxTsGZy_WLhYXLDyyoQiegX61AM6jj7J3BymqBa4aeNvnCqtaM6RY3Fnp7Sl6WlokPSF5PvU8JGivYc7XE/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;code of Prove Numpy Is Faster Than Normal List&quot; data-original-height=&quot;566&quot; data-original-width=&quot;1046&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaEmN4Hzz9qwl0lI5S0jERx5a4bSw7yzDots6BfISftemALQ6jMcIse8rftxxTsGZy_WLhYXLDyyoQiegX61AM6jj7J3BymqBa4aeNvnCqtaM6RY3Fnp7Sl6WlokPSF5PvU8JGivYc7XE/s16000/image.png&quot; title=&quot;code of Prove Numpy Is Faster Than Normal List&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3IChK7wgwBzQfMIb0Fyk8O9X8OTNe2I5ehlcTE7O5v2iuyW7YEjGO2oDMAiLzHR7C78BgxWFQlsrjyt93Kb8BBV_cjF6TVnQj0Hp0PrTIJh_SXJQFd6boUvLIBUDtiFdrkBtq-04nY6c/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;code of Prove Numpy Is Faster Than Normal List&quot; data-original-height=&quot;186&quot; data-original-width=&quot;588&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3IChK7wgwBzQfMIb0Fyk8O9X8OTNe2I5ehlcTE7O5v2iuyW7YEjGO2oDMAiLzHR7C78BgxWFQlsrjyt93Kb8BBV_cjF6TVnQj0Hp0PrTIJh_SXJQFd6boUvLIBUDtiFdrkBtq-04nY6c/s16000/image.png&quot; title=&quot;code of Prove Numpy Is Faster Than Normal List&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcRiHjPhR21tZOmR5AL3jioIb0uOp_lL-EVvPADNszUraWscRE-kTy-uzr8QYgPdB3PNqM95-u7QFsaC6e6zpNgrCSKldPbSj9uUMCZBCW5o6rMmdL96ehMFqkzHA8tGNlYKjpKDTHpYk/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;code of Prove Numpy Is Faster Than Normal List&quot; data-original-height=&quot;642&quot; data-original-width=&quot;1462&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcRiHjPhR21tZOmR5AL3jioIb0uOp_lL-EVvPADNszUraWscRE-kTy-uzr8QYgPdB3PNqM95-u7QFsaC6e6zpNgrCSKldPbSj9uUMCZBCW5o6rMmdL96ehMFqkzHA8tGNlYKjpKDTHpYk/s16000/image.png&quot; title=&quot;code of Prove Numpy Is Faster Than Normal List&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/590635199818946107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/01/prove-numpy-is-faster-than-normal-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/590635199818946107'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/590635199818946107'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/01/prove-numpy-is-faster-than-normal-list.html' title='Prove Numpy Is Faster Than Normal List (python)'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp-ZCjvwx-wdAqLeQE0IpNswLaCYORsB1OPF9tzyWg9TwUsMQXUoLOaLshedNtIYfWpZQxDDJIw43JX8g5l_Phrqmkny34DEVB2-c-zbGuSD_0atHIr2tmG4zDFS0wo26YSpw7kAB76wo/s72-w640-h360-c/image.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-2919636220192423589</id><published>2022-01-08T14:38:00.029+05:30</published><updated>2022-02-07T17:35:42.882+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="converter"/><title type='text'>Number Converter Calculator</title><content type='html'>&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;To convert in 4 main systems:&lt;/h2&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEieMcY02BLaO6r-SAWAvN9O_YB0y5h1W6txsrRxwHn0k6I_SHt8D2vJo1TYMD_uhrcTDQTEPAyGrpK_mY1wmtrzbWYmpCru1SOedyDuDuWxHCSDoZEt6IKgWLnttsPNTrvxy993qXwy__Ykl56-R1ypfyuVHseqEgaeD-Gc8WbFHtngO2emPdMonUI-=s1280&quot;&gt;&lt;img alt=&quot;Number Converter Calculator how to do&quot; border=&quot;0&quot; data-original-height=&quot;624&quot; data-original-width=&quot;1280&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEieMcY02BLaO6r-SAWAvN9O_YB0y5h1W6txsrRxwHn0k6I_SHt8D2vJo1TYMD_uhrcTDQTEPAyGrpK_mY1wmtrzbWYmpCru1SOedyDuDuWxHCSDoZEt6IKgWLnttsPNTrvxy993qXwy__Ykl56-R1ypfyuVHseqEgaeD-Gc8WbFHtngO2emPdMonUI-=s16000&quot; title=&quot;Number Converter Calculator how to do&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;script async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1832089766452330&quot;
     crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
&lt;ins class=&quot;adsbygoogle&quot;
     style=&quot;display:block; text-align:center;&quot;
     data-ad-layout=&quot;in-article&quot;
     data-ad-format=&quot;fluid&quot;
     data-ad-client=&quot;ca-pub-1832089766452330&quot;
     data-ad-slot=&quot;5547237930&quot;&gt;&lt;/ins&gt;
&lt;script&gt;
     (adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;To convert in 2 to 20 base number system:&lt;/h3&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgPJqzDeS34E9EFay4ZqSxyzOwyerOpymj2nHL4OCQZatASDDOJkrwvukzsUHNcwUMCQoarrdjO9LNdwcEUcQJSCdO2OhEUKbfWbC3CO4mQmkb0xcMqOdfOmmMjzDwx3o8HAXfjti3yzzmvq2kZOkeNCa-7QmbzQ4TLGniLlYTxkwKuF_oBtV67VBXU=s1280&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;To convert in 2 to 20 base number system&quot; border=&quot;0&quot; data-original-height=&quot;624&quot; data-original-width=&quot;1280&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgPJqzDeS34E9EFay4ZqSxyzOwyerOpymj2nHL4OCQZatASDDOJkrwvukzsUHNcwUMCQoarrdjO9LNdwcEUcQJSCdO2OhEUKbfWbC3CO4mQmkb0xcMqOdfOmmMjzDwx3o8HAXfjti3yzzmvq2kZOkeNCa-7QmbzQ4TLGniLlYTxkwKuF_oBtV67VBXU=s16000&quot; title=&quot;To convert in 2 to 20 base number system&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Try it:&lt;/h3&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;meta charset=&quot;utf-8&quot;&gt;&lt;/meta&gt;&lt;link href=&quot;https://deep-gajjar.github.io/number-converter-calculator/favicon.png&quot; rel=&quot;icon&quot;&gt;&lt;/link&gt;&lt;meta content=&quot;width=device-width,initial-scale=1&quot; name=&quot;viewport&quot;&gt;&lt;/meta&gt;&lt;meta content=&quot;#000000&quot; name=&quot;theme-color&quot;&gt;&lt;/meta&gt;&lt;meta content=&quot;Number Base Calculator | In this calculator, you can convert any base number to any base number between 2 to 20 base with floating-point values.&quot; name=&quot;description&quot;&gt;&lt;/meta&gt;&lt;link href=&quot;https://deep-gajjar.github.io/number-converter-calculator/favicon.png&quot; rel=&quot;apple-touch-icon&quot;&gt;&lt;/link&gt;&lt;link href=&quot;https://deep-gajjar.github.io/number-converter-calculator/manifest.json&quot; rel=&quot;manifest&quot;&gt;&lt;/link&gt;&lt;link crossorigin=&quot;anonymous&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css&quot; integrity=&quot;sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU&quot; rel=&quot;stylesheet&quot;&gt;&lt;/link&gt;&lt;title id=&quot;title&quot;&gt;Number Converter Calculator&lt;/title&gt;&lt;link href=&quot;https://deep-gajjar.github.io/number-converter-calculator/static/css/main.f14099d0.chunk.css&quot; rel=&quot;stylesheet&quot;&gt;&lt;/link&gt;
    &lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
  &lt;script async=&quot;&quot; src=&quot;https://www.googletagmanager.com/gtag/js?id=G-9790SK3LJ4&quot;&gt;&lt;/script&gt;
  &lt;script&gt;
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(&#39;js&#39;, new Date());
  
    gtag(&#39;config&#39;, &#39;G-9790SK3LJ4&#39;);
  &lt;/script&gt;
    &lt;/head&gt;&lt;body&gt;&lt;noscript&gt;You need to enable JavaScript to run this app.&lt;/noscript&gt;&lt;div id=&quot;root&quot;&gt;&lt;/div&gt;&lt;script crossorigin=&quot;anonymous&quot; integrity=&quot;sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ&quot; src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;&lt;script&gt;!function(e){function r(r){for(var n,a,c=r[0],i=r[1],l=r[2],s=0,p=[];s&lt;c.length;s++)a=c[s],Object.prototype.hasOwnProperty.call(o,a)&amp;&amp;o[a]&amp;&amp;p.push(o[a][0]),o[a]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&amp;&amp;(e[n]=i[n]);for(f&amp;&amp;f(r);p.length;)p.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r&lt;u.length;r++){for(var t=u[r],n=!0,c=1;c&lt;t.length;c++){var i=t[c];0!==o[i]&amp;&amp;(n=!1)}n&amp;&amp;(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,c=document.createElement(&quot;script&quot;);c.charset=&quot;utf-8&quot;,c.timeout=120,a.nc&amp;&amp;c.setAttribute(&quot;nonce&quot;,a.nc),c.src=function(e){return a.p+&quot;static/js/&quot;+({}[e]||e)+&quot;.&quot;+{3:&quot;f7070efb&quot;}[e]+&quot;.chunk.js&quot;}(e);var i=new Error;u=function(r){c.onerror=c.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&amp;&amp;(&quot;load&quot;===r.type?&quot;missing&quot;:r.type),u=r&amp;&amp;r.target&amp;&amp;r.target.src;i.message=&quot;Loading chunk &quot;+e+&quot; failed.\n(&quot;+n+&quot;: &quot;+u+&quot;)&quot;,i.name=&quot;ChunkLoadError&quot;,i.type=n,i.request=u,t[1](i)}o[e]=void 0}};var l=setTimeout((function(){u({type:&quot;timeout&quot;,target:c})}),12e4);c.onerror=c.onload=u,document.head.appendChild(c)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){&quot;undefined&quot;!=typeof Symbol&amp;&amp;Symbol.toStringTag&amp;&amp;Object.defineProperty(e,Symbol.toStringTag,{value:&quot;Module&quot;}),Object.defineProperty(e,&quot;__esModule&quot;,{value:!0})},a.t=function(e,r){if(1&amp;r&amp;&amp;(e=a(e)),8&amp;r)return e;if(4&amp;r&amp;&amp;&quot;object&quot;==typeof e&amp;&amp;e&amp;&amp;e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,&quot;default&quot;,{enumerable:!0,value:e}),2&amp;r&amp;&amp;&quot;string&quot;!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&amp;&amp;e.__esModule?function(){return e.default}:function(){return e};return a.d(r,&quot;a&quot;,r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p=&quot;https://deep-gajjar.github.io/number-converter-calculator/&quot;,a.oe=function(e){throw console.error(e),e};var c=this[&quot;webpackJsonpnumber-converter-calculator&quot;]=this[&quot;webpackJsonpnumber-converter-calculator&quot;]||[],i=c.push.bind(c);c.push=r,c=c.slice();for(var l=0;l&lt;c.length;l++)r(c[l]);var f=i;t()}([])&lt;/script&gt;&lt;script src=&quot;https://deep-gajjar.github.io/number-converter-calculator/static/js/2.e8d4b108.chunk.js&quot;&gt;&lt;/script&gt;&lt;script src=&quot;https://deep-gajjar.github.io/number-converter-calculator/static/js/main.e21a1006.chunk.js&quot;&gt;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;&lt;/div&gt;
&lt;div&gt;&lt;a href=&quot;https://deep-gajjar.github.io/number-converter-calculator&quot; target=&quot;_blank&quot;&gt;open in new tab&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/2919636220192423589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/01/number-converter-calculator.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/2919636220192423589'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/2919636220192423589'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/01/number-converter-calculator.html' title='Number Converter Calculator'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEieMcY02BLaO6r-SAWAvN9O_YB0y5h1W6txsrRxwHn0k6I_SHt8D2vJo1TYMD_uhrcTDQTEPAyGrpK_mY1wmtrzbWYmpCru1SOedyDuDuWxHCSDoZEt6IKgWLnttsPNTrvxy993qXwy__Ykl56-R1ypfyuVHseqEgaeD-Gc8WbFHtngO2emPdMonUI-=s72-c" height="72" width="72"/><thr:total>1</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-5852923089967707671</id><published>2022-01-06T15:00:00.030+05:30</published><updated>2023-01-29T00:57:38.627+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="geometry"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="quadrilateral"/><title type='text'>Find the type of Quadrilateral with given 4 points of the quadrilateral in cpp and python.</title><content type='html'>&lt;h1 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwFOFdxyl45OaS-4v4hYId0E-61qwWXDq3yANQoz0rLzLoZmDgdJ3clNFb36Adrz8ZrsyPKZzgPypBKwcfxeL2-TSiul2nk_M9uUuOrUFsgh09ahy2MgaO7P5l-JqbDpjC-sO5z9YIPmDf1s4seXYO9vCeYm3cmjt_32AJmX2E8pq43lBiQxto3-1x/s1024/Quadrilateral%20with%204%20points.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1001&quot; data-original-width=&quot;1024&quot; height=&quot;626&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwFOFdxyl45OaS-4v4hYId0E-61qwWXDq3yANQoz0rLzLoZmDgdJ3clNFb36Adrz8ZrsyPKZzgPypBKwcfxeL2-TSiul2nk_M9uUuOrUFsgh09ahy2MgaO7P5l-JqbDpjC-sO5z9YIPmDf1s4seXYO9vCeYm3cmjt_32AJmX2E8pq43lBiQxto3-1x/w640-h626/Quadrilateral%20with%204%20points.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/h1&gt;&lt;h1 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Given quadrilateral:&lt;br /&gt;&lt;/span&gt;&lt;/h1&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPx7BRTtaZfN9Yni__25rH1mzM1BJD_sMVdkG24AzaHodqsmC04YC8mtoF8ERgVhPtl4Kq0hvpt-7L3le-1OapUnFvBbhdKxj0cwxnrED9D5BweBcZmR6skaZFwjIvAJ-n4RgCaoD4IME/&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPx7BRTtaZfN9Yni__25rH1mzM1BJD_sMVdkG24AzaHodqsmC04YC8mtoF8ERgVhPtl4Kq0hvpt-7L3le-1OapUnFvBbhdKxj0cwxnrED9D5BweBcZmR6skaZFwjIvAJ-n4RgCaoD4IME/&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsSagTRNQfjk1OYR6cmZGrJ25oXNUYcFTTCeEVqPvthheRykHD6v_tGkR7QGKsvls7J5F4rTPfHFeY3H9-5_eJUJmJ7fMN1hMVgJWHWan_Tf8EZc64lMP75GXo0558gPYDSVlbZU5kHKI/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;given quadrilateral with four points&quot; data-original-height=&quot;360&quot; data-original-width=&quot;695&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsSagTRNQfjk1OYR6cmZGrJ25oXNUYcFTTCeEVqPvthheRykHD6v_tGkR7QGKsvls7J5F4rTPfHFeY3H9-5_eJUJmJ7fMN1hMVgJWHWan_Tf8EZc64lMP75GXo0558gPYDSVlbZU5kHKI/s16000/image.png&quot; title=&quot;given quadrilateral with four points&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;br /&gt;You are only given 4 points of the quadrilaterals.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;question is how can you find the type of given quadrilateral.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;here, points input is in clock wish direction from a,b,c to d.&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;First of all, we are trying to find all measure angles and edges weights.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Use the formula below to find the weights of edges.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7hHArfzybcKA7kzBysRsSa2hZIywtoIbMXjg8wnMo1cvnoVTr_eL9j9DzuKQsDRDNMBWq5CR9AjDn8DUXdK-dL0EKGGx2poYzeDxauMySSqTRPnxBXW0PFDM2vyxxdmJKiX1iwnYKAs8/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;formula of distance between two points&quot; data-original-height=&quot;52&quot; data-original-width=&quot;302&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7hHArfzybcKA7kzBysRsSa2hZIywtoIbMXjg8wnMo1cvnoVTr_eL9j9DzuKQsDRDNMBWq5CR9AjDn8DUXdK-dL0EKGGx2poYzeDxauMySSqTRPnxBXW0PFDM2vyxxdmJKiX1iwnYKAs8/s16000/image.png&quot; title=&quot;formula of distance between two points&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Use the formula below which references to triangle below to find the measure angles of quadrilaterals.&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHpPeM8VGqbwLiagT7xOdqEXISUZ2v3tB6rteGFkKe8_NMS4-XBhrSeOhLJVmBSyQ7kkcjpelgn6bbOgaEGzMvbGis7Hxt5Tc5Yd9W3NgtJ3kWNvf-_C_twE5C_1M_ngYQ47zCgxxZx-c/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;triangle for example&quot; data-original-height=&quot;185&quot; data-original-width=&quot;259&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHpPeM8VGqbwLiagT7xOdqEXISUZ2v3tB6rteGFkKe8_NMS4-XBhrSeOhLJVmBSyQ7kkcjpelgn6bbOgaEGzMvbGis7Hxt5Tc5Yd9W3NgtJ3kWNvf-_C_twE5C_1M_ngYQ47zCgxxZx-c/s16000/image.png&quot; title=&quot;triangle for example&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzIMcbfDZFDwQVULfq1Q-2_1wOqFeNy6AKWb2mX0OYyRrE4yKl57jd1mOFVXPC5SbW1Gqow_6ulen8B0DjxhVq9jebj0hVHHSZy-GP6O6XPxY7u9ngEkjNOxw-tvGPMKyIqsI2Hm3GAPo/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;formula for angle&quot; data-original-height=&quot;62&quot; data-original-width=&quot;357&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzIMcbfDZFDwQVULfq1Q-2_1wOqFeNy6AKWb2mX0OYyRrE4yKl57jd1mOFVXPC5SbW1Gqow_6ulen8B0DjxhVq9jebj0hVHHSZy-GP6O6XPxY7u9ngEkjNOxw-tvGPMKyIqsI2Hm3GAPo/s16000/image.png&quot; title=&quot;formula for angle&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3UaZNQUojXQ-NU1Wi1csd9yqT3BXkQKCkIWjd2k8gnRcxBMGBQdQMiC69VsPRRFxCA04fizzkz0XrqJSbNKvnEXEsqcKy96Czkyig411ZWomZ1J6m_z2ffVxR5FWUdZF5Mhw5XDr5yKE/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3UaZNQUojXQ-NU1Wi1csd9yqT3BXkQKCkIWjd2k8gnRcxBMGBQdQMiC69VsPRRFxCA04fizzkz0XrqJSbNKvnEXEsqcKy96Czkyig411ZWomZ1J6m_z2ffVxR5FWUdZF5Mhw5XDr5yKE/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7eJbfVKdd2SAnXevvzGnj773QwHqbb6G27R52tdjLsuaWUfOYardmCFTEAUtP8LyeIOafSX42gU8AEuhhyphenhyphend0hdMaWkjBE14Xz6Y55cWT5WCNRtokIhPrrzqOWav1-WTqMpPjLD2huLWU/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;angle&quot; data-original-height=&quot;72&quot; data-original-width=&quot;274&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7eJbfVKdd2SAnXevvzGnj773QwHqbb6G27R52tdjLsuaWUfOYardmCFTEAUtP8LyeIOafSX42gU8AEuhhyphenhyphend0hdMaWkjBE14Xz6Y55cWT5WCNRtokIhPrrzqOWav1-WTqMpPjLD2huLWU/s16000/image.png&quot; title=&quot;angle&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYDEmXaw1LBYTGfS89l4GXxnOxR4ejZ7MHpkty3o6m8TUwDhFGgtmiqDPxLoA5JQripdWmoh-mGKiE0UIBC1l4Lky1S-mViiwkwfGLqT_kvh2MnHQkCACNdgX485hGaTa6SevLtAllEQ4/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;angle&quot; data-original-height=&quot;72&quot; data-original-width=&quot;333&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYDEmXaw1LBYTGfS89l4GXxnOxR4ejZ7MHpkty3o6m8TUwDhFGgtmiqDPxLoA5JQripdWmoh-mGKiE0UIBC1l4Lky1S-mViiwkwfGLqT_kvh2MnHQkCACNdgX485hGaTa6SevLtAllEQ4/s16000/image.png&quot; title=&quot;angle&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Here we need to find Diagonal &lt;b&gt;&lt;i&gt;ac &lt;/i&gt;&lt;/b&gt;and &lt;i&gt;&lt;b&gt;bd &lt;/b&gt;&lt;/i&gt;given in the image of the quadrilateral.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Now using conditions we can easily find which type of quadrilateral we have.&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;i&gt;&lt;u&gt;Code in python Image:&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlGoPVx2G4fr8usUCWhooDtkZSLngezxKO9XcMhdoUZsrmINJNjX1PAtvbe-9Sg4lyWAAuFCgZAAY0PVA9Q7TRpaIa2ycFYDYMHKB6-ck_hJrQJIQ9sDaVrJ_XSdHjYqtvZ7VmMwIffIw/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlGoPVx2G4fr8usUCWhooDtkZSLngezxKO9XcMhdoUZsrmINJNjX1PAtvbe-9Sg4lyWAAuFCgZAAY0PVA9Q7TRpaIa2ycFYDYMHKB6-ck_hJrQJIQ9sDaVrJ_XSdHjYqtvZ7VmMwIffIw/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs0UsNPnWLJd4Kf6HDcj9gk55mC1KqHcSEKpgTDUqqKmyFtp6Ulsa3HjB5Q0BvmPELZyTyHN1bhKZ3fVf3F_cHdb2N0ZprrXRr-HwJDXWd_WcOvxtec9tU5yoh4cdyUA7W49L5BPFPllg/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs0UsNPnWLJd4Kf6HDcj9gk55mC1KqHcSEKpgTDUqqKmyFtp6Ulsa3HjB5Q0BvmPELZyTyHN1bhKZ3fVf3F_cHdb2N0ZprrXRr-HwJDXWd_WcOvxtec9tU5yoh4cdyUA7W49L5BPFPllg/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXIgDIVZvptAE1mnZW0QhyphenhyphenLjA0UhxYNxTIc1QDLWowsklZSipc7py0oDtCw5oa6vOtd4AVXhOew_dvIrrEgywqCYoO9weSgHQrqRY18PqZwBPnc6PcVPCxYpsojFtk2dUTcvAPGKQmHQs/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;python code image for finding type of quadrilateral&quot; data-original-height=&quot;2770&quot; data-original-width=&quot;1492&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXIgDIVZvptAE1mnZW0QhyphenhyphenLjA0UhxYNxTIc1QDLWowsklZSipc7py0oDtCw5oa6vOtd4AVXhOew_dvIrrEgywqCYoO9weSgHQrqRY18PqZwBPnc6PcVPCxYpsojFtk2dUTcvAPGKQmHQs/s16000/image.png&quot; title=&quot;python code image for finding type of quadrilateral&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;python Cpp:&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;__name__&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;__main__&quot;&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter 4 point coordinates of quadrilateral separated by space in sequence:&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# read 8 number&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;list&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;map&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;,&lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;().&lt;span style=&quot;color: #dcdcaa;&quot;&gt;split&lt;/span&gt;())) &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# create separate variable for coordinates&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# edge of quadrilateral using edge formula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# finding edge using distance formula.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt;))&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# diagonal of quadrilateral&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# find diagonals.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt;))&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# angles&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# angles of quadrilateral&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# find angle using angle formula.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;A&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;acos&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt;) / (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;B&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;acos&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt;) / (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;C&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;acos&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt;) / (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;))&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;D&lt;/span&gt; = &lt;span style=&quot;color: #4ec9b0;&quot;&gt;math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;acos&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt;) / (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt;))&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# result.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if angles are equal means(90*)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #4fc1ff;&quot;&gt;A&lt;/span&gt; == &lt;span style=&quot;color: #4fc1ff;&quot;&gt;B&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;A&lt;/span&gt; == &lt;span style=&quot;color: #4fc1ff;&quot;&gt;C&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt; &lt;span style=&quot;color: #4fc1ff;&quot;&gt;A&lt;/span&gt; == &lt;span style=&quot;color: #4fc1ff;&quot;&gt;D&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# if edge size are equal&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# square&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is square...&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;area of square :&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# rectangular&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is rectangular...&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;area of square :&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# angles are not equal but edges are equal&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;elif&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# diamond&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is diamond(Rhombus)...&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# opposite edges(sides) are equal&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;elif&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;# parallelogram&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is parallelogram...&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is just a quadrilateral...&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;i&gt;&lt;u&gt;Code in cpp Image:&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlGoPVx2G4fr8usUCWhooDtkZSLngezxKO9XcMhdoUZsrmINJNjX1PAtvbe-9Sg4lyWAAuFCgZAAY0PVA9Q7TRpaIa2ycFYDYMHKB6-ck_hJrQJIQ9sDaVrJ_XSdHjYqtvZ7VmMwIffIw/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlGoPVx2G4fr8usUCWhooDtkZSLngezxKO9XcMhdoUZsrmINJNjX1PAtvbe-9Sg4lyWAAuFCgZAAY0PVA9Q7TRpaIa2ycFYDYMHKB6-ck_hJrQJIQ9sDaVrJ_XSdHjYqtvZ7VmMwIffIw/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs0UsNPnWLJd4Kf6HDcj9gk55mC1KqHcSEKpgTDUqqKmyFtp6Ulsa3HjB5Q0BvmPELZyTyHN1bhKZ3fVf3F_cHdb2N0ZprrXRr-HwJDXWd_WcOvxtec9tU5yoh4cdyUA7W49L5BPFPllg/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;cpp code image for finding type of quadrilateral&quot; data-original-height=&quot;3302&quot; data-original-width=&quot;1524&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs0UsNPnWLJd4Kf6HDcj9gk55mC1KqHcSEKpgTDUqqKmyFtp6Ulsa3HjB5Q0BvmPELZyTyHN1bhKZ3fVf3F_cHdb2N0ZprrXRr-HwJDXWd_WcOvxtec9tU5yoh4cdyUA7W49L5BPFPllg/s16000/image.png&quot; title=&quot;cpp code image for finding type of quadrilateral&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;Code Cpp:&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: arial;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// for input and output:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// for math function cos inverse.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// namespace.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// driver&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter 4 point coordinates of quadrilateral separated by space in sequence:&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // read 8 number&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // create separate variable for coordinates&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;points&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // edge of quadrilateral using edge formula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;float&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // finding edge using distance formula.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt;));&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // diagonal of quadrilateral&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // find diagonals.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;float&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xa&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yc&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ya&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;float&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;xd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;xb&lt;/span&gt;) + (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt;) * (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;yd&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;yb&lt;/span&gt;));&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // angles&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;float&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;B&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;C&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;D&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt; // angles of quadrilateral&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // find angle using angle formula.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;acos&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt;) / (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;B&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;acos&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt;) / (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;C&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;acos&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_bd&lt;/span&gt;) / (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;D&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;acos&lt;/span&gt;((&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; + &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diagonal_ac&lt;/span&gt;) / (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt;));&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // result.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // if angles are equal means(90*)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;B&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;C&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;D&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // if edge size are equal&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // square&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is square...&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;area of square : &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // rectangular&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is rectangular...&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;area of square : &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%f&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // angles are not equal but edges are equal&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // diamond&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is diamond(Rhombus)...&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; // opposite edges(sides) are equal&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // parallelogram&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is parallelogram...&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Quadrilateral is just a quadrilateral...&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;Input:&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;here inputed points are (1,1), (1,0), (0,0) and (0,1).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;output:&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9IIb_g6Venk6HQEvK_2zrHvnUXlfamVEK1nTgeYCl6goxpqYc_02ArsmFh7s9gx6gqLTnr77_RxPQjADXlG6KQGnKShifhQvpsaNMB5UdPGB0UjeWFgUXVMo7e2rEFWq8XHNNV4prpqA/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;result after finding type&quot; data-original-height=&quot;51&quot; data-original-width=&quot;583&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9IIb_g6Venk6HQEvK_2zrHvnUXlfamVEK1nTgeYCl6goxpqYc_02ArsmFh7s9gx6gqLTnr77_RxPQjADXlG6KQGnKShifhQvpsaNMB5UdPGB0UjeWFgUXVMo7e2rEFWq8XHNNV4prpqA/s16000/image.png&quot; title=&quot;result after finding type&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Read also:&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/09/python-string-formatting-best-example-with-the-best-explanation.html&quot;&gt;Python string-formatting best example.&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/09/how-to-create-own-header-files-in-cpp-and-inside-header-files-how-to-create-functions-and-objects-and-also-use-them.html&quot;&gt;Creating header file in cpp.&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/5852923089967707671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/01/find-type-of-quadrilateral-with-given-points.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/5852923089967707671'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/5852923089967707671'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2022/01/find-type-of-quadrilateral-with-given-points.html' title='Find the type of Quadrilateral with given 4 points of the quadrilateral in cpp and python.'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwFOFdxyl45OaS-4v4hYId0E-61qwWXDq3yANQoz0rLzLoZmDgdJ3clNFb36Adrz8ZrsyPKZzgPypBKwcfxeL2-TSiul2nk_M9uUuOrUFsgh09ahy2MgaO7P5l-JqbDpjC-sO5z9YIPmDf1s4seXYO9vCeYm3cmjt_32AJmX2E8pq43lBiQxto3-1x/s72-w640-h626-c/Quadrilateral%20with%204%20points.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>22.7415772 79.276812499999991</georss:point><georss:box>-7.2581077465169592 44.120562499999991 52.741262146516959 114.43306249999999</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-8273023331310685582</id><published>2021-09-01T18:11:00.005+05:30</published><updated>2022-01-11T23:19:54.293+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="string"/><title type='text'> python string formatting example with the explanation</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2s0I6HOG3OQE5A9jVDMX80A8TtBYerQDoyYpNMRsAKy0Gf1fYBIBnVnbDf5aAGUXcBWgA8xvQ4ds6KAUEZ7HnSHpjcV5cychXAJPO9bERPJ9rq48Wrz4Wf7ZurKqT48DUy4TFzUVljV8/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;python string formatting&quot; data-original-height=&quot;1300&quot; data-original-width=&quot;867&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2s0I6HOG3OQE5A9jVDMX80A8TtBYerQDoyYpNMRsAKy0Gf1fYBIBnVnbDf5aAGUXcBWgA8xvQ4ds6KAUEZ7HnSHpjcV5cychXAJPO9bERPJ9rq48Wrz4Wf7ZurKqT48DUy4TFzUVljV8/w427-h640/image.png&quot; title=&quot;python string formatting&quot; width=&quot;427&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Preview what we going to learn:&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTxZQg4AI_G5d5Nag7BbAReqe7EACXypX7xcAtj59nH3SiUb6ltAcE39EMa_1MMHnxQVoOlFMIpr0Su9wzQznO7a013vs1ce4B66xr_q9ZeCdWw_AG1T6A17PO52FWBgwBniZjCQGHIcE/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;1060&quot; data-original-width=&quot;1278&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTxZQg4AI_G5d5Nag7BbAReqe7EACXypX7xcAtj59nH3SiUb6ltAcE39EMa_1MMHnxQVoOlFMIpr0Su9wzQznO7a013vs1ce4B66xr_q9ZeCdWw_AG1T6A17PO52FWBgwBniZjCQGHIcE/s16000/image.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 class=&quot;western&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span&gt;&lt;span style=&quot;font-family: georgia; font-size: 15pt;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Write
a program in Python using the following scenario:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;p align=&quot;justify&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;
&lt;span style=&quot;font-family: georgia; font-size: 13pt;&quot;&gt;Your
customer is a restaurant owner that wants to be able to advertise
online in chat rooms, but they have an ever-changing menu. Write a
program in Python that will prompt the user for the name of a
restaurant, three menu items, and their prices. See example input and
output below.&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;justify&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;font-size: 17.3333px;&quot;&gt;This is the solution to the assignment which you can download &lt;a href=&quot;https://drive.google.com/file/d/15zNGd1JjkvVULOp0Flx9ltYKqMX9reUL/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 class=&quot;western&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span style=&quot;font-size: 13pt; font-weight: normal;&quot;&gt;&lt;i&gt;Example:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;h4 class=&quot;western&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;i&gt;Input:&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;Famous&amp;nbsp;Bill&#39;s&amp;nbsp;Eatery&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;BLT&amp;nbsp;Sandwich&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;11.99&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;Fries&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1.49&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;Drink&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1.19&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;h4 class=&quot;western&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh6ZWn1Zn3o6fSeRaBmDr2eWuWkgefQTjTSor658vdYyD8d6poIL4lRoTGocF6RpGpF-AzPhvak9zfv0A9V9wqRd8kKMl2KD80G0Jp_D6xUX2sBPgejkQAfa0NE3PoroUAi2kQyqFGpb8/s397/string_formating_output.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh6ZWn1Zn3o6fSeRaBmDr2eWuWkgefQTjTSor658vdYyD8d6poIL4lRoTGocF6RpGpF-AzPhvak9zfv0A9V9wqRd8kKMl2KD80G0Jp_D6xUX2sBPgejkQAfa0NE3PoroUAi2kQyqFGpb8/s397/string_formating_output.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh6ZWn1Zn3o6fSeRaBmDr2eWuWkgefQTjTSor658vdYyD8d6poIL4lRoTGocF6RpGpF-AzPhvak9zfv0A9V9wqRd8kKMl2KD80G0Jp_D6xUX2sBPgejkQAfa0NE3PoroUAi2kQyqFGpb8/s397/string_formating_output.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha5kUJojOUkych2qv58vIXg8PHBA9bFGOMbDm7Lrr4cVXGPm-C05hbg47SNLqpYwb1LAG9zE_0V_p8V8PwZzRznMYeVXKG6Qmr876ZALIJI6yxcNhEwnTD6ETFwqhfEJJUikjzMHkHGYg/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha5kUJojOUkych2qv58vIXg8PHBA9bFGOMbDm7Lrr4cVXGPm-C05hbg47SNLqpYwb1LAG9zE_0V_p8V8PwZzRznMYeVXKG6Qmr876ZALIJI6yxcNhEwnTD6ETFwqhfEJJUikjzMHkHGYg/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKBJnzRWVcLzM1BDMFtJ2iJIHzyIc7psfgSX7bTVW8e7r10Aykm8N-Nikx5HEz1fBM9fIuPOBsrlCQTtNZoMrwnbdyGidwhySUEvGJH7cDBV2mORbEn1yaB_CoX4-CQYw2Hctl84VmHhw/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;output of python string&quot; data-original-height=&quot;124&quot; data-original-width=&quot;250&quot; height=&quot;159&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKBJnzRWVcLzM1BDMFtJ2iJIHzyIc7psfgSX7bTVW8e7r10Aykm8N-Nikx5HEz1fBM9fIuPOBsrlCQTtNZoMrwnbdyGidwhySUEvGJH7cDBV2mORbEn1yaB_CoX4-CQYw2Hctl84VmHhw/w320-h159/image.png&quot; title=&quot;output of python string&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;h3 class=&quot;western&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;u&gt;&lt;i style=&quot;font-weight: normal;&quot;&gt;Python
code:&lt;/i&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;max&amp;nbsp;len&amp;nbsp;25&lt;/span&gt;&lt;/div&gt;&lt;div&gt;restaurant&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;item&amp;nbsp;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;max&amp;nbsp;len&amp;nbsp;12&lt;/span&gt;&lt;/div&gt;&lt;div&gt;item1&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;max&amp;nbsp;99.99&lt;/span&gt;&lt;/div&gt;&lt;div&gt;item1_price&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;float&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;())&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;item&amp;nbsp;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;item2&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;item2_price&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;float&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;())&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;item&amp;nbsp;3&lt;/span&gt;&lt;/div&gt;&lt;div&gt;item3&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;item3_price&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;float&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;input&lt;/span&gt;())&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;size&amp;nbsp;of&amp;nbsp;display&amp;nbsp;33&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;br&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;*&#39;&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;33&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(br)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;a&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{}{:^25}{}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;*&#39;&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;,&amp;nbsp;restaurant,&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;*&#39;&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(a)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(br)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;b&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;*&amp;nbsp;&quot;&lt;/span&gt;+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;lt;23}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(item1)+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;gt;6}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;$&#39;&lt;/span&gt;+&lt;span style=&quot;color: #4ec9b0;&quot;&gt;str&lt;/span&gt;(item1_price))+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;*&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(b)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;c&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;*&amp;nbsp;&quot;&lt;/span&gt;+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;lt;23}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(item2)+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;gt;6}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;$&#39;&lt;/span&gt;+&lt;span style=&quot;color: #4ec9b0;&quot;&gt;str&lt;/span&gt;(item2_price))+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;*&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(c)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;d&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;*&amp;nbsp;&quot;&lt;/span&gt;+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;lt;23}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(item3)+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;gt;6}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;$&#39;&lt;/span&gt;+&lt;span style=&quot;color: #4ec9b0;&quot;&gt;str&lt;/span&gt;(item3_price))+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;*&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(d)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(br)&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 class=&quot;western&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;i&gt;Terminal
output and input:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTB2542MLfJ9GdwA98QEBMhKzYLE4eRkAWPAN1RynZJ8CYq9YjGsyhQ1A7ua2s0BDwOsMiLSIIbg9s2bdkGabyfElXoWhTmHnlx_SXHMUNuIZCOgHWAGCjRmf0DLnIkBhUL5IK2QF9zWw/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;309&quot; data-original-width=&quot;660&quot; height=&quot;251&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTB2542MLfJ9GdwA98QEBMhKzYLE4eRkAWPAN1RynZJ8CYq9YjGsyhQ1A7ua2s0BDwOsMiLSIIbg9s2bdkGabyfElXoWhTmHnlx_SXHMUNuIZCOgHWAGCjRmf0DLnIkBhUL5IK2QF9zWw/w510-h251/image.png&quot; width=&quot;510&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 class=&quot;western&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;
&lt;span style=&quot;font-family: georgia;&quot;&gt;There
are many ways to solve this problem but we can use string formatting
in python to do this task accurately.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;h4 class=&quot;western&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;i style=&quot;font-weight: normal;&quot;&gt;Example:&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;s&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;var&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;s&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;this&amp;nbsp;is&amp;nbsp;a&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(var)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;h4 class=&quot;western&quot;&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;p class=&quot;normal&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 13pt; line-height: 115%; mso-bidi-font-family: Georgia; mso-fareast-font-family: Georgia;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;These
are normal examples of string formatting.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4 class=&quot;western&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: courier; font-weight: normal;&quot;&gt;&lt;i&gt;printing output:&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;1)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;br&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;*&#39;&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;33&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(br)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;
&lt;span style=&quot;font-family: georgia;&quot;&gt;This print  &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;‘*’ 33&lt;/b&gt; &lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;times in the first
row.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;2)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;a&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{}{:^25}{}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;*&#39;&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;,&amp;nbsp;restaurant,&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;*&#39;&lt;/span&gt;*&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(a)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;Here
&lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;&lt;span&gt;“{:^25}”&lt;/span&gt;&lt;span&gt;.format(restaurant)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt; formats string and create &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;25 &lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;length
string with restaurant name in the center-aligned of the string.&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;3)&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;b&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;*&amp;nbsp;&quot;&lt;/span&gt;+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;lt;23}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(item1)+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;gt;6}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;$&#39;&lt;/span&gt;+&lt;span style=&quot;color: #4ec9b0;&quot;&gt;str&lt;/span&gt;(item1_price))+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;*&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(b)&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;
&lt;span&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;Here
&lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;“{:&amp;lt;23}”.format(item1)&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt; formats string and create &lt;/span&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;b&gt;23 &lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;length
string with item1 value left-aligned.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;and
Here &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;“{:&amp;gt;6}”.format(item1_price)&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt; formats string and create 6
length string &lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;with item1_price value right-aligned. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;

&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;i&gt;&lt;b&gt;Repeat
this step for item 2 and 3:&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;c&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;*&amp;nbsp;&quot;&lt;/span&gt;+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;lt;23}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(item2)+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;gt;6}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;$&#39;&lt;/span&gt;+&lt;span style=&quot;color: #4ec9b0;&quot;&gt;str&lt;/span&gt;(item2_price))+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;*&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(c)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;d&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;*&amp;nbsp;&quot;&lt;/span&gt;+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;lt;23}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(item3)+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;{:&amp;gt;6}&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;.format(&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;$&#39;&lt;/span&gt;+&lt;span style=&quot;color: #4ec9b0;&quot;&gt;str&lt;/span&gt;(item3_price))+&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;*&quot;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(d)&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;span style=&quot;font-size: 13pt;&quot;&gt;4)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span style=&quot;font-family: Georgia, serif;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(br)&lt;/div&gt;&lt;/div&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;
&lt;span&gt;&lt;span style=&quot;font-family: georgia; font-size: 13pt;&quot;&gt;This
is the end of the display.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;margin-bottom: 0.35cm; text-align: left;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt; font-weight: normal;&quot;&gt;&lt;i&gt;These are python articles you like...:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithm-implementation-in-python.html&quot; target=&quot;_blank&quot;&gt;All Sorting Algorithm Implementation in Python&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/print-n-rows-of-pascals-triangle-in-cpp-and-python.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;Print N Rows of Pascal&#39;s Triangle in C++ and Python&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;Image of code:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjesQrMzjT5aZ60gSJrSOKabniUH3SScRIwF_f24kuVr9iD6J4KpF3AIBPawyPZXYlXeKHKOvZ16X0a4SvX-fjcudmVU861wt-vAvrdoseLCvEU6_eINi5UafRTXNvaSSn1P5EXppQKexc/&quot;&gt;&lt;img alt=&quot;python string formatting example code&quot; data-original-height=&quot;1478&quot; data-original-width=&quot;1280&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjesQrMzjT5aZ60gSJrSOKabniUH3SScRIwF_f24kuVr9iD6J4KpF3AIBPawyPZXYlXeKHKOvZ16X0a4SvX-fjcudmVU861wt-vAvrdoseLCvEU6_eINi5UafRTXNvaSSn1P5EXppQKexc/s16000/image.png&quot; title=&quot;python string formatting example code&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 13pt;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: georgia; font-size: 13pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;margin-bottom: 0.35cm;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: georgia; font-size: 13pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/8273023331310685582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/09/python-string-formatting-best-example-with-the-best-explanation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8273023331310685582'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8273023331310685582'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/09/python-string-formatting-best-example-with-the-best-explanation.html' title=' python string formatting example with the explanation'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2s0I6HOG3OQE5A9jVDMX80A8TtBYerQDoyYpNMRsAKy0Gf1fYBIBnVnbDf5aAGUXcBWgA8xvQ4ds6KAUEZ7HnSHpjcV5cychXAJPO9bERPJ9rq48Wrz4Wf7ZurKqT48DUy4TFzUVljV8/s72-w427-h640-c/image.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-3243047885644356173</id><published>2021-09-01T17:09:00.006+05:30</published><updated>2022-01-11T23:26:17.528+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="header file"/><category scheme="http://www.blogger.com/atom/ns#" term="objects"/><title type='text'> how to create own header files in cpp? and inside, header files how to create functions and objects and also use them?</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgQhc6Nnc4KdmGzyPVKb05Yb-avl6649_FcMaXp7k9gPg__3yPSK4esdtwmMEFSw4K7jlydLsESLj8SnDmiDh5oIF03UjaVsINY0nKXiO03LcUcJzYa8uTfGUJaX35mvfWE5laG1YQr-9v7sig4ilrQVp2W8YmCdo15bOpaTwIKQE5QLy1l_bT6aJsd=s310&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;164&quot; data-original-width=&quot;310&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgQhc6Nnc4KdmGzyPVKb05Yb-avl6649_FcMaXp7k9gPg__3yPSK4esdtwmMEFSw4K7jlydLsESLj8SnDmiDh5oIF03UjaVsINY0nKXiO03LcUcJzYa8uTfGUJaX35mvfWE5laG1YQr-9v7sig4ilrQVp2W8YmCdo15bOpaTwIKQE5QLy1l_bT6aJsd=w400-h212&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i style=&quot;font-weight: normal;&quot;&gt;&lt;div style=&quot;background-color: white; color: #292929; font-family: Lora, serif; font-size: 18px; font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Preview what we going to learn:&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgDVIxxqD34eHfu2FBvSLsYX-0FWYhmeVHusJXShaQsV3iHQn7LJIDVTaA50mQtoMPnpSOvcWKQQ2dz91qsCxw8l375l9EEZMIquCAVVCdCGD2d6UQwpU7WKeMfPWHn42OWL-qp68qaW4Y__jUFC0AQYnIZL9YAOrgFUz7Ffd7_CQeICn6-yvBUKcQk=s1402&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;created header file&quot; border=&quot;0&quot; data-original-height=&quot;1402&quot; data-original-width=&quot;1218&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgDVIxxqD34eHfu2FBvSLsYX-0FWYhmeVHusJXShaQsV3iHQn7LJIDVTaA50mQtoMPnpSOvcWKQQ2dz91qsCxw8l375l9EEZMIquCAVVCdCGD2d6UQwpU7WKeMfPWHn42OWL-qp68qaW4Y__jUFC0AQYnIZL9YAOrgFUz7Ffd7_CQeICn6-yvBUKcQk=s16000&quot; title=&quot;created header file&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style=&quot;background-color: white; color: #292929; font-family: Lora, serif; font-size: 18px; font-style: normal;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i style=&quot;font-weight: normal;&quot;&gt;This is also the solution to this assignment you can download this &lt;a href=&quot;https://drive.google.com/file/d/15New_3woxqG6pa9dq27hxAjFcjBuAhyJ/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;file&lt;/a&gt;.&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;line-height: 100%; margin-bottom: 0cm; text-align: left;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-weight: normal;&quot;&gt;Here 3 files are
created &lt;/span&gt;&lt;span style=&quot;font-family: courier; font-weight: normal;&quot;&gt;&lt;u&gt;date.hpp&lt;/u&gt;, &lt;u&gt;date.cpp&lt;/u&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: georgia; font-weight: normal;&quot;&gt;and &lt;/span&gt;&lt;span style=&quot;font-family: courier; font-weight: normal;&quot;&gt;&lt;u&gt;main.cpp&lt;/u&gt;&lt;/span&gt;&lt;span style=&quot;font-family: georgia; font-weight: normal;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Arial, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;/h3&gt;&lt;h3 style=&quot;line-height: 100%; margin-bottom: 0.56cm; text-align: left;&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 15pt;&quot;&gt;&lt;u style=&quot;font-weight: normal;&quot;&gt;&lt;i&gt;date.hpp&lt;/i&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0.56cm;&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;u&gt;&lt;i&gt;&lt;span style=&quot;font-family: courier; font-size: 15pt;&quot;&gt;&lt;/span&gt;&lt;/i&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;lt;ctime&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#ifndef&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;DATE_H&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;This&amp;nbsp;definition&amp;nbsp;&amp;nbsp;protect&amp;nbsp;the&amp;nbsp;header&amp;nbsp;against&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;#define&amp;nbsp;DATE_H&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;multiple&amp;nbsp;inclusions.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;date&amp;nbsp;class&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;private:&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Data&amp;nbsp;fields&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;day&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//day&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;month&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//month&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;year&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;year&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;public:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;constructor&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Date&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;constructor&amp;nbsp;for&amp;nbsp;seting&amp;nbsp;value&amp;nbsp;at&amp;nbsp;declartion&amp;nbsp;time&amp;nbsp;in&amp;nbsp;d/m/y&amp;nbsp;form.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Date&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;data&amp;nbsp;seting&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;Date&amp;nbsp;to&amp;nbsp;d/m/y.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateSet&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateDay&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;accessing&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;Day.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateMonth&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;accessing&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;Month.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateYear&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;accessing&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;Year.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;ToString&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;returns&amp;nbsp;string&amp;nbsp;form&amp;nbsp;of&amp;nbsp;date.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DatePrint&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;prints&amp;nbsp;Date.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;};&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateNow&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;accessing&amp;nbsp;todays&amp;nbsp;date.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#endif&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4; font-family: Consolas, Courier New, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;#ifndef DATE_H&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;#define
DATE_H&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;	//
our code.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;#endif&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0.56cm;&quot;&gt;



&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Using In this method we can protect the header against multiple inclusions.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
	&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;date.hpp
	file only contain declarations.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/li&gt;&lt;/ol&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;


&lt;/p&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;&lt;br /&gt;

&lt;/p&gt;&lt;h4 style=&quot;line-height: 100%; margin-bottom: 0cm; text-align: left;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;u&gt;Declarations in Date
class&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;u&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;/span&gt;&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;date&amp;nbsp;class&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;private:&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Data&amp;nbsp;fields&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;day&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//day&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;month&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//month&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;year&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;year&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Consolas, Courier New, monospace; font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;public:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;constructor&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Date&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;constructor&amp;nbsp;for&amp;nbsp;seting&amp;nbsp;value&amp;nbsp;at&amp;nbsp;declartion&amp;nbsp;time&amp;nbsp;in&amp;nbsp;d/m/y&amp;nbsp;form.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Date&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;);&lt;/div&gt;&lt;span style=&quot;font-family: Consolas, Courier New, monospace; font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;data&amp;nbsp;seting&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;Date&amp;nbsp;to&amp;nbsp;d/m/y.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateSet&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;);&lt;/div&gt;&lt;span style=&quot;font-family: Consolas, Courier New, monospace; font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateDay&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;accessing&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;Day.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateMonth&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;accessing&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;Month.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateYear&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;accessing&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;Year.&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Consolas, Courier New, monospace; font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;ToString&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;returns&amp;nbsp;string&amp;nbsp;form&amp;nbsp;of&amp;nbsp;date.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DatePrint&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;prints&amp;nbsp;Date.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-weight: normal;&quot;&gt;};&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h3&gt;&lt;h4 style=&quot;line-height: 100%; margin-bottom: 0cm; text-align: left;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: 100%; margin-bottom: 0cm; text-align: left;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;u&gt;We declare a function
DateNow() out of class&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateNow&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;accessing&amp;nbsp;todays&amp;nbsp;date.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;line-height: 100%; margin-bottom: 0.56cm; text-align: left;&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 15pt; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;line-height: 100%; margin-bottom: 0.56cm; text-align: left;&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 15pt; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;u&gt;date.cpp&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;i&gt;&lt;u&gt;&lt;span style=&quot;font-family: courier; font-size: 15pt;&quot;&gt;&lt;/span&gt;&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;ctime&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;header&amp;nbsp;for&amp;nbsp;accessing&amp;nbsp;current&amp;nbsp;time.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;date.hpp&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//All&amp;nbsp;implimentation&amp;nbsp;of&amp;nbsp;&quot;date.hpp&quot;&amp;nbsp;is&amp;nbsp;here:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;function&amp;nbsp;to&amp;nbsp;convert&amp;nbsp;date&amp;nbsp;in&amp;nbsp;to&amp;nbsp;string&amp;nbsp;form&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;ToString&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&amp;nbsp;s&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;to_string&lt;/span&gt;(day);&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;/&#39;&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;to_string&lt;/span&gt;(month);&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;/&#39;&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;to_string&lt;/span&gt;(year);&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;s;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Default&amp;nbsp;constructor.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Date&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateSet&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;constructor&amp;nbsp;for&amp;nbsp;setting&amp;nbsp;value&amp;nbsp;at&amp;nbsp;declartion&amp;nbsp;time.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Date&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;d,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;m,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;y)&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateSet&lt;/span&gt;(d,&amp;nbsp;m,&amp;nbsp;y);&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;method&amp;nbsp;for&amp;nbsp;setting&amp;nbsp;value&amp;nbsp;of&amp;nbsp;date&amp;nbsp;object.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateSet&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;m&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;day&amp;nbsp;=&amp;nbsp;d;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;month&amp;nbsp;=&amp;nbsp;m;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;year&amp;nbsp;=&amp;nbsp;y;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;access&amp;nbsp;day.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateDay&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;day;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;access&amp;nbsp;month.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateMonth&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;month;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;access&amp;nbsp;year.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateYear&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;year;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;mathod&amp;nbsp;for&amp;nbsp;printing&amp;nbsp;date.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;::&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DatePrint&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;ToString&lt;/span&gt;()&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;function&amp;nbsp;for&amp;nbsp;creating&amp;nbsp;date&amp;nbsp;object&amp;nbsp;of&amp;nbsp;today&#39;s&amp;nbsp;date.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Date&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateNow&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Default&amp;nbsp;value.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Date&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;d&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1970&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;time_t&lt;/span&gt;&amp;nbsp;t&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;time&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;0L&lt;/span&gt;);&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Stores&amp;nbsp;the&amp;nbsp;current&amp;nbsp;time&amp;nbsp;in&amp;nbsp;t.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(t&amp;nbsp;==&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;time_t&lt;/span&gt;)(-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;d;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tm&amp;nbsp;*tp;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;In&amp;nbsp;C&amp;nbsp;this&amp;nbsp;would&amp;nbsp;have&amp;nbsp;been&amp;nbsp;struct&amp;nbsp;tm&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tp&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;localtime&lt;/span&gt;(&amp;amp;t);&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Turns&amp;nbsp;t&amp;nbsp;into&amp;nbsp;a&amp;nbsp;tm&amp;nbsp;structure&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;setting&amp;nbsp;date.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Perversely,&amp;nbsp;months&amp;nbsp;are&amp;nbsp;0-11&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;The&amp;nbsp;tm&amp;nbsp;structure&amp;nbsp;uses&amp;nbsp;2-digit&amp;nbsp;years&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateSet&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tp&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_mday&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tp&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_mon&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tp&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tm_year&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1900&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;return&amp;nbsp;object&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;d;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;All
	setter and getter methods of class Date are implemented here.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
	&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;You
	can see comments on the code for details.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h4 style=&quot;line-height: 100%; margin-bottom: 0.42cm; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;i style=&quot;font-weight: normal;&quot;&gt;More articles on cpp&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: courier; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithms-in-cpp.html&quot; target=&quot;_blank&quot;&gt;All Sorting Algorithms Implementation In c++&lt;/a&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: courier; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/search/label/prefix%20sum?&amp;amp;max-results=5&quot; target=&quot;_blank&quot;&gt;Prefix sums&lt;/a&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: courier; font-weight: normal;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/search/label/Algorithm?&amp;amp;max-results=7&quot; target=&quot;_blank&quot;&gt;algos&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: courier; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;u&gt;main.cpp&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;lt;string&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;date.hpp&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;date.cpp&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;date.hpp&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;driver&amp;nbsp;code&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;testing&amp;nbsp;constructor.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Date&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;d&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;20&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2021&lt;/span&gt;);&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;d&amp;nbsp;object&amp;nbsp;is&amp;nbsp;created.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;testing&amp;nbsp;setter&amp;nbsp;method.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Date&amp;nbsp;v;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;v&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateSet&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;19&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2021&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;testing&amp;nbsp;of&amp;nbsp;DatePrint();&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;d:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DatePrint&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;v:&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;v&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DatePrint&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;testing&amp;nbsp;getter&amp;nbsp;mathod.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Values&amp;nbsp;of&amp;nbsp;date&amp;nbsp;v&amp;nbsp;:&quot;&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;v.day&amp;nbsp;&amp;nbsp;:&quot;&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;v&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateDay&lt;/span&gt;()&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;v.month:&quot;&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;v&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateMonth&lt;/span&gt;()&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;v.year&amp;nbsp;:&quot;&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;v&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateYear&lt;/span&gt;()&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;testing&amp;nbsp;ToString()&amp;nbsp;mathod.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;String&amp;nbsp;form&amp;nbsp;of&amp;nbsp;date&amp;nbsp;v&amp;nbsp;:&quot;&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;v&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;ToString&lt;/span&gt;()&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;testing&amp;nbsp;DateNow()&amp;nbsp;function&amp;nbsp;which&amp;nbsp;gives&amp;nbsp;todays&amp;nbsp;date.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Date&amp;nbsp;today&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;DateNow&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cout&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;Todays&amp;nbsp;Date&amp;nbsp;:&quot;&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;today&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;ToString&lt;/span&gt;()&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;endl;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;span style=&quot;font-family: Consolas, Courier New, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h3 style=&quot;line-height: 100%; margin-bottom: 0.56cm; text-align: left;&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;p style=&quot;line-height: 100%; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;color: black; font-family: georgia; font-size: small; font-weight: normal;&quot;&gt;Testing
	of all methods of an object, Date is done here.&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia; font-size: small;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;line-height: 100%; margin-bottom: 0.56cm; text-align: left;&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;span style=&quot;font-family: courier; font-size: 15pt; font-weight: normal;&quot;&gt;&lt;i&gt;&lt;u&gt;Output&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-family: Arial, serif; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_ICXqbdVxb6Y8bsETC4jh1-J5Z_R0zEU-G7DRg9smpWYie5KW4IX04DeNCr_jejRpRWTVAIlD9NIxH0Kiafp3YFG2cv_X2NWA77IsEtCQUKNPJBqxK_Ed5Ig6vl5McId0QHvJQhhLQT8/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;how to create own header files in cpp&quot; data-original-height=&quot;229&quot; data-original-width=&quot;451&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_ICXqbdVxb6Y8bsETC4jh1-J5Z_R0zEU-G7DRg9smpWYie5KW4IX04DeNCr_jejRpRWTVAIlD9NIxH0Kiafp3YFG2cv_X2NWA77IsEtCQUKNPJBqxK_Ed5Ig6vl5McId0QHvJQhhLQT8/w561-h283/image.png&quot; title=&quot;how to create own header files in cpp&quot; width=&quot;561&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial, serif;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Arial, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;all code Images:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;data.hpp&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjiopJQ7fnnkYT1qeRle4sFMZ83ID40c8CZnnDw8WT95CUoW8EsFGh8Ihygc9GKhf_JAE6pGkU24hl9XBJBSMhFLJjEOrYl2BwW-tO0oyQHjh4AXDkt6-h5Iz7s1_EXPOE6vs0smECqsi_xZCViikYGhZyYePqJE7sGrIADKjIFv9-7SXjUBt0mS9ga=s1402&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;data.hpp header&quot; border=&quot;0&quot; data-original-height=&quot;1402&quot; data-original-width=&quot;1216&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjiopJQ7fnnkYT1qeRle4sFMZ83ID40c8CZnnDw8WT95CUoW8EsFGh8Ihygc9GKhf_JAE6pGkU24hl9XBJBSMhFLJjEOrYl2BwW-tO0oyQHjh4AXDkt6-h5Iz7s1_EXPOE6vs0smECqsi_xZCViikYGhZyYePqJE7sGrIADKjIFv9-7SXjUBt0mS9ga=s16000&quot; title=&quot;data.hpp header&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;data.cpp&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: courier;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiA3RPqt3kv1eeWANHs82Q_e76RgcX4jgTU72FmhIlkqWveBUnyRkI2msQUtY4-oGaugqlSLZs2q-q5ObH0kHyp-6M1YUqXx2AuAY7UiTNm_FkZJG665l6daYxgms2apAB_2X5NOBblSDrSdfst1hKBMtblyrHb0A_q8iIRcnv_5z9w9A9gZJqZPPpM=s3378&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;data.cpp implementation&quot; border=&quot;0&quot; data-original-height=&quot;3378&quot; data-original-width=&quot;1124&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEiA3RPqt3kv1eeWANHs82Q_e76RgcX4jgTU72FmhIlkqWveBUnyRkI2msQUtY4-oGaugqlSLZs2q-q5ObH0kHyp-6M1YUqXx2AuAY7UiTNm_FkZJG665l6daYxgms2apAB_2X5NOBblSDrSdfst1hKBMtblyrHb0A_q8iIRcnv_5z9w9A9gZJqZPPpM=s16000&quot; title=&quot;data.cpp implementation&quot; /&gt;&lt;/a&gt;&lt;/div&gt;main.cpp&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh-_fX7ysSQfoXJt0w8Xr6CgcX-QEsa28SyKd4sBmpj0Ja47rH2YqDzLjSa7OxPFC_mTuVicHxOCEXvSiCvOEBIgWaFBpOfOzqhChdVkpuqicWMf9rVPKYktuN3LPp_mzpkwQtzDycFAg2ezfN9a8eS2c4KzoUM_Ya8uLHm-TqKKUUiUnwuHphJcSaD=s1592&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;main.cpp testing&quot; border=&quot;0&quot; data-original-height=&quot;1592&quot; data-original-width=&quot;1138&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh-_fX7ysSQfoXJt0w8Xr6CgcX-QEsa28SyKd4sBmpj0Ja47rH2YqDzLjSa7OxPFC_mTuVicHxOCEXvSiCvOEBIgWaFBpOfOzqhChdVkpuqicWMf9rVPKYktuN3LPp_mzpkwQtzDycFAg2ezfN9a8eS2c4KzoUM_Ya8uLHm-TqKKUUiUnwuHphJcSaD=s16000&quot; title=&quot;main.cpp testing&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/3243047885644356173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/09/how-to-create-own-header-files-in-cpp-and-inside-header-files-how-to-create-functions-and-objects-and-also-use-them.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3243047885644356173'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3243047885644356173'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/09/how-to-create-own-header-files-in-cpp-and-inside-header-files-how-to-create-functions-and-objects-and-also-use-them.html' title=' how to create own header files in cpp? and inside, header files how to create functions and objects and also use them?'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEgQhc6Nnc4KdmGzyPVKb05Yb-avl6649_FcMaXp7k9gPg__3yPSK4esdtwmMEFSw4K7jlydLsESLj8SnDmiDh5oIF03UjaVsINY0nKXiO03LcUcJzYa8uTfGUJaX35mvfWE5laG1YQr-9v7sig4ilrQVp2W8YmCdo15bOpaTwIKQE5QLy1l_bT6aJsd=s72-w400-h212-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-4403060016626215742</id><published>2021-08-06T11:24:00.005+05:30</published><updated>2022-08-28T12:57:48.409+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="3d"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="prefix sum"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Queries For Finding Sum Between Two Cells Of 3D Integers Array.</title><content type='html'>&lt;h1 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT5L1r2YBlcDdqD_14cMjifYDVteJk6HADUvC36AgbskbDOhpvVSES1tH_y_PVTLUPnysr4c1Eju_Yxe6enEQFfMuE_EqReGvITdhN4yHonAsQzeM14M3WoRY77hRyTkyHiWXCsRf_2qk/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Sum Between Two Cells Of 3D Integers Array&quot; data-original-height=&quot;1253&quot; data-original-width=&quot;1880&quot; height=&quot;427&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT5L1r2YBlcDdqD_14cMjifYDVteJk6HADUvC36AgbskbDOhpvVSES1tH_y_PVTLUPnysr4c1Eju_Yxe6enEQFfMuE_EqReGvITdhN4yHonAsQzeM14M3WoRY77hRyTkyHiWXCsRf_2qk/w640-h427/image.png&quot; title=&quot;Sum Between Two Cells Of 3D Integers Array&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h1&gt;&lt;h1 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;prerequisite: &lt;/span&gt;&lt;u style=&quot;font-family: georgia;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-3d-array.html&quot; target=&quot;_blank&quot;&gt;Prefix Sum – 3D&lt;/a&gt;&lt;/u&gt;&lt;/h1&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Given a 3-Dimensional array of integers &lt;strong&gt;A[L][R][C].&lt;/strong&gt; where &lt;strong&gt;L, R,&lt;/strong&gt; and &lt;strong&gt;C &lt;/strong&gt;are dimensions of the array (Layer, Row, Column). &amp;nbsp;there are large number of queries to find the sum of integers between given cells inclusively. &lt;i&gt;&lt;strong&gt;(find the sum of sub 3d array of the given array).&lt;/strong&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;similar articles for 2d array matrix: &lt;/i&gt;&lt;i&gt;&lt;strong&gt;Submatrix Sum Queries&lt;/strong&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;The total number of Queries is &lt;strong&gt;Q&lt;/strong&gt;. Each query consist of 6 integers k1,i1,j1,k2,i2,j2 indexes of array, and you have to answer sum of integers between &lt;strong&gt;A[k1][i1][j1]&lt;/strong&gt; and &lt;strong&gt;A[k2][i2][j2] &lt;/strong&gt;inclusively.&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Example:&lt;/span&gt;&lt;/h2&gt;&lt;pre&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;&lt;strong&gt;Input:&lt;/strong&gt;&lt;/i&gt;
&lt;i&gt;array:&lt;/i&gt;
&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Layer&amp;nbsp;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;}},&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Layer&amp;nbsp;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;}},&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Layer&amp;nbsp;3&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;}},&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Layer&amp;nbsp;4&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;}}&lt;/div&gt;&lt;div&gt;};&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;	
&lt;i&gt;Queries:&lt;/i&gt;
&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;query&lt;/span&gt;&amp;nbsp;=&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;i&gt;All Query is in form of k1,i1,j1,k2,i2,j2.&lt;/i&gt;
&lt;i&gt;here 4 query are given.&lt;/i&gt;

&lt;i&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/i&gt;
&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px;&quot;&gt;&lt;div&gt;Query&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Query&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;27&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Query&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;36&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Query&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;64&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/span&gt;&lt;/pre&gt;&lt;h2&gt;&lt;i&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Approach:&lt;/span&gt;&lt;/i&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;First of all, calculate the &lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-one-dimensional-array.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;prefix sum&lt;/u&gt;&lt;/a&gt; of given array &lt;strong&gt;A[L][R][C].&lt;/strong&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;and then collect indexes of two given cells from the query array.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;store prefix sum up to &lt;strong&gt;A[k2][i2][j2]&lt;/strong&gt;.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;store&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;up&amp;nbsp;to&amp;nbsp;A[k2][i2][j2]:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j2&lt;/span&gt;];&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;apply following operations using if conditions to remove unnecessary cells and remove overlapping.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;unnecessary&amp;nbsp;cells&amp;nbsp;and&amp;nbsp;overlaping&amp;nbsp;removal&amp;nbsp;steps&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;using&amp;nbsp;if&amp;nbsp;conditions&amp;nbsp;:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j2&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j2&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j2&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k2&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i2&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h2&gt;&lt;i&gt;&lt;strong&gt;Implementation:&lt;/strong&gt;&lt;/i&gt;&lt;/h2&gt;&lt;p&gt;&lt;i&gt;All calculation of prefix sum is taken from &lt;/i&gt;&lt;i&gt;&lt;strong&gt;&lt;u&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-3d-array.html&quot; target=&quot;_blank&quot;&gt;prefix sum of 3d array&lt;/a&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/i&gt;&lt;i&gt;&lt;strong&gt;&lt;u&gt;.&lt;/u&gt;&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;strong&gt;C++ Implementation:&lt;/strong&gt;&lt;/i&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;C++&amp;nbsp;program&amp;nbsp;for&amp;nbsp;the&amp;nbsp;above&amp;nbsp;approach.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Declaring&amp;nbsp;size&amp;nbsp;of&amp;nbsp;the&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Layer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Row&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Column&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Calculating&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;prefixSum3d&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;],&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;0:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;1:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;first&amp;nbsp;row,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;column,&amp;nbsp;and&amp;nbsp;pile&amp;nbsp;of&amp;nbsp;ceils.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;1d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;L;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;2:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;cells&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;of&amp;nbsp;sides(made&amp;nbsp;up&amp;nbsp;using&amp;nbsp;cells)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;which&amp;nbsp;have&amp;nbsp;common&amp;nbsp;element&amp;nbsp;A[0][0][0].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;on&amp;nbsp;2d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;L;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;L;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;3:&amp;nbsp;Filling&amp;nbsp;value&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;in&amp;nbsp;remaining&amp;nbsp;cells&amp;nbsp;using&amp;nbsp;formula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;L;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;we&amp;nbsp;don&#39;t&amp;nbsp;have&amp;nbsp;to&amp;nbsp;return&amp;nbsp;pre&amp;nbsp;array&amp;nbsp;because&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;pre&amp;nbsp;array&amp;nbsp;is&amp;nbsp;passed&amp;nbsp;by&amp;nbsp;reference&lt;/span&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Driver&amp;nbsp;Code&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;given&amp;nbsp;array:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Layer&amp;nbsp;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;}},&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Layer&amp;nbsp;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;}},&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Layer&amp;nbsp;3&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;}},&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Layer&amp;nbsp;4&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;}}};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;given&amp;nbsp;queries:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;query&lt;/span&gt;&amp;nbsp;=&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;}};&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Q&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;query&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;prefixSum3d&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;Q&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;collect&amp;nbsp;indexes&amp;nbsp;of&amp;nbsp;two&amp;nbsp;given&amp;nbsp;cells&amp;nbsp;from&amp;nbsp;the&amp;nbsp;query&amp;nbsp;array:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k2&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i2&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j2&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;store&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;up&amp;nbsp;to&amp;nbsp;A[k2][i2][j2]:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j2&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;unnecessary&amp;nbsp;cells&amp;nbsp;and&amp;nbsp;overlaping&amp;nbsp;removal&amp;nbsp;steps&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;using&amp;nbsp;if&amp;nbsp;conditions&amp;nbsp;:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j2&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k2&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j2&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j2&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k2&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i2&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;pre&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j1&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;printing&amp;nbsp;answer:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Query&amp;nbsp;&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;:&amp;nbsp;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;strong&gt;Python Implementation:&lt;/strong&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;python&amp;nbsp;program&amp;nbsp;to&amp;nbsp;calculate&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;3d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Declaring&amp;nbsp;size&amp;nbsp;of&amp;nbsp;the&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;L&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;R&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Row&lt;/span&gt;&lt;/div&gt;&lt;div&gt;C&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Column&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Calculating&amp;nbsp;prefix&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;prefixSum3d&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;A&lt;/span&gt;):&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre&amp;nbsp;=&amp;nbsp;[[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(C)]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(R)]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;d&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(L)]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;A[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Step&amp;nbsp;1:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;first&amp;nbsp;row,column,&amp;nbsp;and&amp;nbsp;pile&amp;nbsp;of&amp;nbsp;ceils.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;1d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;L):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;pre[i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;A[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;A[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i]&amp;nbsp;=&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;A[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Step&amp;nbsp;2:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;cells&amp;nbsp;of&amp;nbsp;sides(made&amp;nbsp;up&amp;nbsp;using&amp;nbsp;cells)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;which&amp;nbsp;have&amp;nbsp;common&amp;nbsp;element&amp;nbsp;A[0][0][0].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;on&amp;nbsp;2d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;L):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre[k][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;(A[k][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;pre[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;pre[k][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;pre[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][j]&amp;nbsp;=&amp;nbsp;(A[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][j]&amp;nbsp;+&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&amp;nbsp;+&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;L):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre[k][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j]&amp;nbsp;=&amp;nbsp;(A[k][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j]&amp;nbsp;+&amp;nbsp;pre[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j]&amp;nbsp;+&amp;nbsp;pre[k][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;pre[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Step&amp;nbsp;3:&amp;nbsp;Filling&amp;nbsp;value&amp;nbsp;in&amp;nbsp;remaining&amp;nbsp;cells&amp;nbsp;using&amp;nbsp;formula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;L):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pre[k][i][j]&amp;nbsp;=&amp;nbsp;(A[k][i][j]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;pre[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i][j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;pre[k][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;pre[k][i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;pre[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;pre[k][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;pre[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;pre[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;pre&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Driver&amp;nbsp;program&amp;nbsp;to&amp;nbsp;test&amp;nbsp;above&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;given&amp;nbsp;array:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;A&amp;nbsp;=&amp;nbsp;[&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&amp;nbsp;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]],&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&amp;nbsp;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]],&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&amp;nbsp;3&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]],&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&amp;nbsp;4&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]]&lt;/div&gt;&lt;div&gt;]&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;given&amp;nbsp;queries:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;query&amp;nbsp;=&amp;nbsp;[&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;]&lt;/div&gt;&lt;div&gt;Q&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(query)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;calculating&amp;nbsp;prefix&amp;nbsp;sum:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;pre&amp;nbsp;=&amp;nbsp;prefixSum3d(A)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;calculating&amp;nbsp;answer&amp;nbsp;for&amp;nbsp;each&amp;nbsp;query:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(Q):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;collect&amp;nbsp;indexes&amp;nbsp;of&amp;nbsp;two&amp;nbsp;given&amp;nbsp;cells&amp;nbsp;from&amp;nbsp;the&amp;nbsp;query&amp;nbsp;array:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;k1&amp;nbsp;=&amp;nbsp;query[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i1&amp;nbsp;=&amp;nbsp;query[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j1&amp;nbsp;=&amp;nbsp;query[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;k2&amp;nbsp;=&amp;nbsp;query[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i2&amp;nbsp;=&amp;nbsp;query[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j2&amp;nbsp;=&amp;nbsp;query[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;store&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;up&amp;nbsp;to&amp;nbsp;A[k2][i2][j2]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;=&amp;nbsp;pre[k2][i2][j2]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;overlaping&amp;nbsp;removal&amp;nbsp;steps&amp;nbsp;using&amp;nbsp;if&amp;nbsp;conditions&amp;nbsp;:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;j1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;pre[k2][i2][j1-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;k1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;pre[k1-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i2][j2]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;i1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;pre[k2][i1-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j2]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;k1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt;&amp;nbsp;i1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+=&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j2]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;i1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt;&amp;nbsp;j1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+=&amp;nbsp;pre[k2][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;j1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt;&amp;nbsp;k1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+=&amp;nbsp;pre[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i2][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;k1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt;&amp;nbsp;i1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt;&amp;nbsp;j1&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;-=&amp;nbsp;pre[k1-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i1-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j1-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;printing&amp;nbsp;answer:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Query&quot;&lt;/span&gt;,&amp;nbsp;i+&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;:&amp;nbsp;&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sum&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #080000;&quot;&gt;&lt;h2&gt;&lt;i&gt;Complexity:&lt;/i&gt;&lt;/h2&gt;&lt;h3&gt;&lt;i&gt;Prefix sum:&amp;nbsp;&lt;/i&gt;&lt;/h3&gt;&lt;p&gt;&lt;i&gt;&lt;strong&gt;Time Complexity:&lt;/strong&gt; O(L*R*C) &amp;nbsp;&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;&lt;strong&gt;Auxiliary Space:&lt;/strong&gt; O(L*R*C)&lt;/i&gt;&lt;/p&gt;&lt;h3&gt;&lt;i&gt;Query:&lt;/i&gt;&lt;/h3&gt;&lt;p&gt;&lt;i&gt;Here all Query Answer takes &lt;strong&gt;O(1)&lt;/strong&gt; Time, &lt;/i&gt;the &lt;i&gt;total time complexity is &lt;strong&gt;O(Q).&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;and space &lt;/i&gt;required&lt;i&gt; is &lt;strong&gt;O(Q*6).&lt;/strong&gt;&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;&lt;strong&gt;Time Complexity:&lt;/strong&gt; O(Q)&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;&lt;strong&gt;Auxiliary Space:&lt;/strong&gt; O(Q)&lt;/i&gt;&lt;/p&gt;&lt;h3&gt;&lt;i&gt;Final Complexity:&lt;/i&gt;&lt;/h3&gt;&lt;p&gt;&lt;i&gt;&lt;strong&gt;Time Complexity: &lt;/strong&gt;O(L*R*C+Q) &amp;nbsp;&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;&lt;strong&gt;Auxiliary Space: &lt;/strong&gt;O(L*R*C+Q)&lt;/i&gt;&lt;/p&gt;C++ image:&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #080000;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr5EK6CPsDS74MKWUG0W267GpaSldslKTJKdhdvdw_VPTfjfQUItcALMKT2AP2XpB6JDLlO0GAxF9oaRMT9Xfqf5nGdaeVW1ngiIlSAIShji4biLJKj8z_wGypwcHZgmKhZIN8cfPmQ6o/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Queries For Finding Sum Between Two Cells Of 3D Integers Array in cpp&quot; data-original-height=&quot;6152&quot; data-original-width=&quot;1694&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr5EK6CPsDS74MKWUG0W267GpaSldslKTJKdhdvdw_VPTfjfQUItcALMKT2AP2XpB6JDLlO0GAxF9oaRMT9Xfqf5nGdaeVW1ngiIlSAIShji4biLJKj8z_wGypwcHZgmKhZIN8cfPmQ6o/s16000/image.png&quot; title=&quot;Queries For Finding Sum Between Two Cells Of 3D Integers Array in cpp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Python image:&lt;/div&gt;&lt;div style=&quot;background-color: white; color: #080000;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqVGPRom4POwP0KM0Kn0sRIL13DYcZJOdkvaVHS4l8JVYS5S-NZGf8tYn7mXnVb9SZRaO4N-m21Gckz3v_MZjhhBC4M7asw58-894B393T1i2CP3tpS4MqX81cyHzFDKLS8BViktYlhO4/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Queries For Finding Sum Between Two Cells Of 3D Integers Array in python&quot; data-original-height=&quot;5126&quot; data-original-width=&quot;1340&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqVGPRom4POwP0KM0Kn0sRIL13DYcZJOdkvaVHS4l8JVYS5S-NZGf8tYn7mXnVb9SZRaO4N-m21Gckz3v_MZjhhBC4M7asw58-894B393T1i2CP3tpS4MqX81cyHzFDKLS8BViktYlhO4/s16000/image.png&quot; title=&quot;Queries For Finding Sum Between Two Cells Of 3D Integers Array in python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Read also:&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #080000;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/09/python-string-formatting-best-example-with-the-best-explanation.html&quot;&gt;python string formatting best example with the best explanation&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #080000;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/09/how-to-create-own-header-files-in-cpp-and-inside-header-files-how-to-create-functions-and-objects-and-also-use-them.html&quot;&gt;how to create own header files in cpp? and inside, header files how to create functions and objects and also use them?&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/4403060016626215742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/08/queries-for-finding-sum-between-two-cells-of-3d-integers-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/4403060016626215742'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/4403060016626215742'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/08/queries-for-finding-sum-between-two-cells-of-3d-integers-array.html' title='Queries For Finding Sum Between Two Cells Of 3D Integers Array.'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT5L1r2YBlcDdqD_14cMjifYDVteJk6HADUvC36AgbskbDOhpvVSES1tH_y_PVTLUPnysr4c1Eju_Yxe6enEQFfMuE_EqReGvITdhN4yHonAsQzeM14M3WoRY77hRyTkyHiWXCsRf_2qk/s72-w640-h427-c/image.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-28.561298558846797 8.6503799999999984 69.7486665588468 149.27537999999998</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-3000126155641425191</id><published>2021-07-28T13:11:00.005+05:30</published><updated>2022-01-11T23:35:01.016+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>All Sorting Algorithm Implementation in Python</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg6pWopds_mt3GBePol1_g7LWcjbLXdjuwgvUhglWd13H0FuQFiUUx1e1CoPERuZRR9R9NU8P6FAgjhg2vrlqKO2qyBFD2uzwHTVgSJLjB_0S_5qhz_KWvEoZlSslcb14kF9fDrK3QcR202Ta98TIrqZNWIy0oHHjUdSj9iPLTVG8CLiGfkBn-VBkjl=s1880&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Sorting Algorithm Implementation in Python&quot; border=&quot;0&quot; data-original-height=&quot;1058&quot; data-original-width=&quot;1880&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg6pWopds_mt3GBePol1_g7LWcjbLXdjuwgvUhglWd13H0FuQFiUUx1e1CoPERuZRR9R9NU8P6FAgjhg2vrlqKO2qyBFD2uzwHTVgSJLjB_0S_5qhz_KWvEoZlSslcb14kF9fDrK3QcR202Ta98TIrqZNWIy0oHHjUdSj9iPLTVG8CLiGfkBn-VBkjl=w640-h360&quot; title=&quot;Sorting Algorithm Implementation in Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span&gt;Here you can find all Implementation of sorting algorithms in python which sorts the array in I&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #202124; font-size: 16px;&quot;&gt;ncreasing Order (&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #202124; font-size: 16px;&quot;&gt;Ascending&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #202124; font-size: 16px;&quot;&gt;&amp;nbsp;Order)&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #202124; font-size: 16px;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Bubble sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Insertion sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Selection sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Merge sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #202124; font-family: georgia; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;Read Also:&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithms-in-cpp.html&quot; target=&quot;_blank&quot;&gt;All Sorting Algorithm In C++&lt;/a&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Bubble Sort:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px; white-space: pre;&quot;&gt;&lt;div style=&quot;font-size: 18px; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;python&amp;nbsp;implementation&amp;nbsp;of&amp;nbsp;Bubble&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Bubble&amp;nbsp;Sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;bubble_sort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;iterate&amp;nbsp;i&amp;nbsp;from&amp;nbsp;0&amp;nbsp;to&amp;nbsp;n-1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(n):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;variable&amp;nbsp;for&amp;nbsp;checking&amp;nbsp;if&amp;nbsp;swap&amp;nbsp;is&amp;nbsp;done&amp;nbsp;or&amp;nbsp;not&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;swapped&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;iterate&amp;nbsp;j&amp;nbsp;form&amp;nbsp;0&amp;nbsp;to&amp;nbsp;n-2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(n-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;compare&amp;nbsp;two&amp;nbsp;neighbors&amp;nbsp;at&amp;nbsp;j&amp;nbsp;index&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;arr[j]&amp;nbsp;&amp;gt;&amp;nbsp;arr[j&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;if&amp;nbsp;first&amp;nbsp;is&amp;nbsp;greater&amp;nbsp;than&amp;nbsp;second&amp;nbsp;then&amp;nbsp;swap&amp;nbsp;element&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;swapping&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arr[j],&amp;nbsp;arr[j+&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;arr[j+&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;],&amp;nbsp;arr[j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;swapping&amp;nbsp;is&amp;nbsp;done&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;swapped&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;if&amp;nbsp;swapping&amp;nbsp;is&amp;nbsp;not&amp;nbsp;done&amp;nbsp;then&amp;nbsp;arr&amp;nbsp;is&amp;nbsp;sorted&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;then&amp;nbsp;return&amp;nbsp;function&amp;nbsp;to&amp;nbsp;break&amp;nbsp;for&amp;nbsp;loop&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;swapped&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Driver&amp;nbsp;code:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;arr&amp;nbsp;=&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;323&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;65&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;n&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(arr)&lt;/div&gt;&lt;div&gt;bubble_sort(arr,&amp;nbsp;n)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;printing&amp;nbsp;sorted&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(n):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(arr[i],&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;sorted&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;65&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;323&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Insertion Sort:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 19.8px; line-height: 26px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;font-size: 18px; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;python&amp;nbsp;implementation&amp;nbsp;of&amp;nbsp;insertion&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;insertion&amp;nbsp;sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;insertion_sort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;iterate&amp;nbsp;i&amp;nbsp;form&amp;nbsp;1&amp;nbsp;to&amp;nbsp;n-1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;n):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;here&amp;nbsp;arr[0...i-1]&amp;nbsp;is&amp;nbsp;sorted&amp;nbsp;in&amp;nbsp;every&amp;nbsp;iteration&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;key&amp;nbsp;which&amp;nbsp;we&amp;nbsp;will&amp;nbsp;inserting&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;key&amp;nbsp;=&amp;nbsp;arr[i]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;point&amp;nbsp;to&amp;nbsp;last&amp;nbsp;element&amp;nbsp;of&amp;nbsp;sorted&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;shift&amp;nbsp;elements&amp;nbsp;greater&amp;nbsp;than&amp;nbsp;key&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt;&amp;nbsp;arr[j]&amp;nbsp;&amp;gt;&amp;nbsp;key:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arr[j&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;arr[j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;please&amp;nbsp;key&amp;nbsp;element&amp;nbsp;to&amp;nbsp;appropriate&amp;nbsp;please&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arr[j&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;key&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Driver&amp;nbsp;code:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;arr&amp;nbsp;=&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;65&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;n&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(arr)&lt;/div&gt;&lt;div&gt;insertion_sort(arr,&amp;nbsp;n)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;printing&amp;nbsp;sorted&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(n):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(arr[i],&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 19.8px; line-height: 26px; white-space: pre;&quot;&gt;&lt;div&gt;sorted&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;65&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Selection Sort:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h3&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;font-size: 18px; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;python&amp;nbsp;implementation&amp;nbsp;of&amp;nbsp;selection&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;selection&amp;nbsp;sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;selection_sort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;iterate&amp;nbsp;i&amp;nbsp;from&amp;nbsp;0&amp;nbsp;to&amp;nbsp;n-2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(n-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;consider&amp;nbsp;arr[i...n]&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;min_index&amp;nbsp;=&amp;nbsp;i&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;find&amp;nbsp;min&amp;nbsp;element&amp;nbsp;index&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(i&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;n):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;arr[min_index]&amp;nbsp;&amp;gt;&amp;nbsp;arr[j]:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;min_index&amp;nbsp;=&amp;nbsp;j&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;swapping&amp;nbsp;min&amp;nbsp;element&amp;nbsp;with&amp;nbsp;first&amp;nbsp;element&amp;nbsp;for&amp;nbsp;array.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arr[i],&amp;nbsp;arr[min_index]&amp;nbsp;=&amp;nbsp;arr[min_index],&amp;nbsp;arr[i]&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Driver&amp;nbsp;code:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;arr&amp;nbsp;=&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;67895&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;99999&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;n&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(arr)&lt;/div&gt;&lt;div&gt;selection_sort(arr,&amp;nbsp;n)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;printing&amp;nbsp;sorted&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(n):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(arr[i],&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h3 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;sorted&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;67895&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;99999&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h2 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Merge Sort:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h3 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div style=&quot;background-color: white; color: black; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;python&amp;nbsp;program&amp;nbsp;for&amp;nbsp;merge&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Merge&amp;nbsp;to&amp;nbsp;subarray&amp;nbsp;of&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;first_array&amp;nbsp;=&amp;nbsp;array[start..mid]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;second_array&amp;nbsp;=&amp;nbsp;array[mid+1..end]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Merge&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;creating&amp;nbsp;to&amp;nbsp;temp&amp;nbsp;subarray&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;first_array&amp;nbsp;=&amp;nbsp;[]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;second_array&amp;nbsp;=&amp;nbsp;[]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;copy&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(start,&amp;nbsp;mid+&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;first_array.append(array[i])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;copy&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(mid&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;end+&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;second_array.append(array[i])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;index&amp;nbsp;reference&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;for&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;for&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;main_i&amp;nbsp;=&amp;nbsp;start&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;for&amp;nbsp;main&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size_1&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(first_array)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;size&amp;nbsp;of&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size_2&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(second_array)&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;size&amp;nbsp;of&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;merge&amp;nbsp;subarray&amp;nbsp;first_array&amp;nbsp;and&amp;nbsp;second_array&amp;nbsp;into&amp;nbsp;array[start..end]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&amp;lt;&amp;nbsp;size_1&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;size_2:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;first_array[i]&amp;nbsp;&amp;lt;=&amp;nbsp;second_array[j]:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;array[main_i]&amp;nbsp;=&amp;nbsp;first_array[i]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;array[main_i]&amp;nbsp;=&amp;nbsp;second_array[j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;main_i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;copy&amp;nbsp;remaining&amp;nbsp;element&amp;nbsp;of&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&amp;lt;&amp;nbsp;size_1:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;array[main_i]&amp;nbsp;=&amp;nbsp;first_array[i]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;main_i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;copy&amp;nbsp;remaining&amp;nbsp;element&amp;nbsp;of&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;size_2:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;array[main_i]&amp;nbsp;=&amp;nbsp;second_array[j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;main_i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;main&amp;nbsp;merge&amp;nbsp;Sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;mergeSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;start&amp;nbsp;&amp;gt;=&amp;nbsp;end:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;finding&amp;nbsp;mid&amp;nbsp;point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mid&amp;nbsp;=&amp;nbsp;start&amp;nbsp;+&amp;nbsp;(end&amp;nbsp;-&amp;nbsp;start)&amp;nbsp;//&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;divide&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mergeSort(array,&amp;nbsp;start,&amp;nbsp;mid)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mergeSort(array,&amp;nbsp;mid&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;end)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;conquer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Merge(array,&amp;nbsp;start,&amp;nbsp;mid,&amp;nbsp;end)&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;driver&amp;nbsp;code&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;declaring&amp;nbsp;&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;array&amp;nbsp;=&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;78&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;n&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(array)&lt;/div&gt;&lt;div&gt;mergeSort(array,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;n&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;array&amp;nbsp;is&amp;nbsp;sorted&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array:&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(n):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(array[i],&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h3 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;sorted&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;78&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;Read Also:&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/merge-sort.html&quot; target=&quot;_blank&quot;&gt;Merge Sort Algorithm&lt;/a&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Image of code:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Bubble sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #202124; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhJBnFFaVN3TvKMUfB7rArHqc5p6eSr4G8ZnIDUbXiQA-ySHyfJvpch7_6h_fNZqFVt6GocuaUHeOhPe1EgBW1KswjpflyhCobUfA49mAFXWnzGm17ntWZrUtsJfwR6Vzq1Nxxcg4SPsulahDbjoas18-fvuTJh4YkfwYmgVO2Rs4Z-ESZjDAYgGocM=s1440&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;bubble sort in python&quot; border=&quot;0&quot; data-original-height=&quot;1440&quot; data-original-width=&quot;1186&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhJBnFFaVN3TvKMUfB7rArHqc5p6eSr4G8ZnIDUbXiQA-ySHyfJvpch7_6h_fNZqFVt6GocuaUHeOhPe1EgBW1KswjpflyhCobUfA49mAFXWnzGm17ntWZrUtsJfwR6Vzq1Nxxcg4SPsulahDbjoas18-fvuTJh4YkfwYmgVO2Rs4Z-ESZjDAYgGocM=s16000&quot; title=&quot;bubble sort in python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Insertion sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #202124; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhp2tvesBd5tnx3qX8W9apSV_hBUCRgS6u-0F9O6y3MeE9qRPAwGJ-bQAFtZqK8wmNHhQt29LnCsWLjw0BdskRFU-VBF9st4MLhuRWFNchktCn-lMIho9310FyXUIiNUsHdXLXScX2Cbakg16J8rqNCejJcPAP38sg_7CJT0hZgGHyReKtSfvHvVaUb=s1364&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;insertion sort in python&quot; border=&quot;0&quot; data-original-height=&quot;1364&quot; data-original-width=&quot;1018&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhp2tvesBd5tnx3qX8W9apSV_hBUCRgS6u-0F9O6y3MeE9qRPAwGJ-bQAFtZqK8wmNHhQt29LnCsWLjw0BdskRFU-VBF9st4MLhuRWFNchktCn-lMIho9310FyXUIiNUsHdXLXScX2Cbakg16J8rqNCejJcPAP38sg_7CJT0hZgGHyReKtSfvHvVaUb=s16000&quot; title=&quot;insertion sort in python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Selection sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #202124; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgj3kA3DBvZD6GR9q0RsV1nz924FN_xOcOlDgTEhVzKymK2IX6q-j3VShKMAsUMBXR-opsSYn_zcNZL3MTDncgAc_bgNp84heQuP3Xj2PGI_LNgeO4Mpk_B8x301SzgTwGcNhzTDF1f9sBzodgOZgq-sFWJ0YbfRj3_5m0Nd1DyT0PcF8giZzbkV_XF=s1174&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;selection sort in python&quot; border=&quot;0&quot; data-original-height=&quot;1174&quot; data-original-width=&quot;1080&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgj3kA3DBvZD6GR9q0RsV1nz924FN_xOcOlDgTEhVzKymK2IX6q-j3VShKMAsUMBXR-opsSYn_zcNZL3MTDncgAc_bgNp84heQuP3Xj2PGI_LNgeO4Mpk_B8x301SzgTwGcNhzTDF1f9sBzodgOZgq-sFWJ0YbfRj3_5m0Nd1DyT0PcF8giZzbkV_XF=s16000&quot; title=&quot;selection sort in python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Merge sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #202124; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg7aHk5CLOwiKSDKjmiwZcK9HTURJaGhF44sqetUj5MwcgmcP_GghNbin481arVBE4RQatcKtYYwxF_zAMzzSzTbi7dB7pakkeTM000jal-5lhC2fP7zj2-7DOYbNU2ztCsXcpr-dnpgsao8Q6hBcwS2WggjGwjg2JHET0CLenxHHNl0AdyBZEkCHuu=s2998&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;merge sort in python&quot; border=&quot;0&quot; data-original-height=&quot;2998&quot; data-original-width=&quot;1264&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEg7aHk5CLOwiKSDKjmiwZcK9HTURJaGhF44sqetUj5MwcgmcP_GghNbin481arVBE4RQatcKtYYwxF_zAMzzSzTbi7dB7pakkeTM000jal-5lhC2fP7zj2-7DOYbNU2ztCsXcpr-dnpgsao8Q6hBcwS2WggjGwjg2JHET0CLenxHHNl0AdyBZEkCHuu=s16000&quot; title=&quot;merge sort in python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/3000126155641425191/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithm-implementation-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3000126155641425191'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3000126155641425191'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithm-implementation-in-python.html' title='All Sorting Algorithm Implementation in Python'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEg6pWopds_mt3GBePol1_g7LWcjbLXdjuwgvUhglWd13H0FuQFiUUx1e1CoPERuZRR9R9NU8P6FAgjhg2vrlqKO2qyBFD2uzwHTVgSJLjB_0S_5qhz_KWvEoZlSslcb14kF9fDrK3QcR202Ta98TIrqZNWIy0oHHjUdSj9iPLTVG8CLiGfkBn-VBkjl=s72-w640-h360-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-3961446754793717272</id><published>2021-07-26T17:41:00.041+05:30</published><updated>2022-01-11T23:36:20.557+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>All Sorting Algorithms Implementation In c++</title><content type='html'>&lt;h1 style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi_PdT2GM5sYCZKQlSZP1tnfmTR4rATwFI50klkQWul-t2fcJ5NIRzKj3QCzECMdBhOoRjl4yz2IqtajfPiqOaZEjTQ2uEbC1n4C6Um4_ocWZXJvNirguVPSPmFknym4xF2VdIKGlstn_myy0T7MPuAptOP-caN7-0fCS5FD66R3HoUh7e4A1v7fny3=s1880&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Sorting Algorithms Implementation In cpp&quot; border=&quot;0&quot; data-original-height=&quot;1058&quot; data-original-width=&quot;1880&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEi_PdT2GM5sYCZKQlSZP1tnfmTR4rATwFI50klkQWul-t2fcJ5NIRzKj3QCzECMdBhOoRjl4yz2IqtajfPiqOaZEjTQ2uEbC1n4C6Um4_ocWZXJvNirguVPSPmFknym4xF2VdIKGlstn_myy0T7MPuAptOP-caN7-0fCS5FD66R3HoUh7e4A1v7fny3=w640-h360&quot; title=&quot;Sorting Algorithms Implementation In cpp&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;All Sorting Algorithms&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;In c++: B&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;est Sorting Algorithm Code in cpp&lt;/i&gt;&lt;/span&gt;&lt;/h1&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span&gt;Here you can find all Implementation of sorting algorithms in c++ which sorts the array in I&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #202124; font-size: 16px;&quot;&gt;ncreasing Order (&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #202124; font-size: 16px;&quot;&gt;Ascending&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #202124; font-size: 16px;&quot;&gt;&amp;nbsp;Order)&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #202124; font-size: 16px;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Bubble sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Insertion sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Selection sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Merge sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;b style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;color: #202124;&quot;&gt;Read Also:&lt;/span&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithm-implementation-in-python.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border-color: initial; border-image: initial; border-style: initial; outline-color: initial; outline-style: initial; transition-duration: 0.17s; transition-property: color;&quot;&gt;All Sorting Algorithm In&amp;nbsp;&lt;/span&gt;&lt;/span&gt;python&lt;/span&gt;&lt;/a&gt;&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Bubble Sort:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;c++&amp;nbsp;implementation&amp;nbsp;of&amp;nbsp;Bubble&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Bubble&amp;nbsp;Sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;bubble_sort&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[],&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;iterate&amp;nbsp;i&amp;nbsp;from&amp;nbsp;0&amp;nbsp;to&amp;nbsp;n-1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;variable&amp;nbsp;for&amp;nbsp;checking&amp;nbsp;if&amp;nbsp;swap&amp;nbsp;is&amp;nbsp;done&amp;nbsp;or&amp;nbsp;not&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;swapped&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;iterate&amp;nbsp;j&amp;nbsp;form&amp;nbsp;0&amp;nbsp;to&amp;nbsp;n-2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;compare&amp;nbsp;two&amp;nbsp;neighbors&amp;nbsp;at&amp;nbsp;j&amp;nbsp;index&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;if&amp;nbsp;first&amp;nbsp;is&amp;nbsp;greater&amp;nbsp;than&amp;nbsp;second&amp;nbsp;then&amp;nbsp;swap&amp;nbsp;element&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;swapping&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;;&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;swapping&amp;nbsp;is&amp;nbsp;done&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;swapped&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;if&amp;nbsp;swapping&amp;nbsp;is&amp;nbsp;not&amp;nbsp;done&amp;nbsp;then&amp;nbsp;arr&amp;nbsp;is&amp;nbsp;sorted&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;then&amp;nbsp;return&amp;nbsp;function&amp;nbsp;to&amp;nbsp;break&amp;nbsp;for&amp;nbsp;loop&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;swapped&lt;/span&gt;&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;}&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Driver&amp;nbsp;code:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[]&amp;nbsp;=&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;323&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;65&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;};&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;)&amp;nbsp;/&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]);&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;bubble_sort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;);&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;printing&amp;nbsp;sorted&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array:&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;sorted&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;65&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;323&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Insertion Sort:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 19.8px; line-height: 26px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;font-size: 18px; line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;c++&amp;nbsp;implementation&amp;nbsp;of&amp;nbsp;insertion&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;insertion&amp;nbsp;sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;insertion_sort&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[],&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;iterate&amp;nbsp;i&amp;nbsp;form&amp;nbsp;1&amp;nbsp;to&amp;nbsp;n-1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;here&amp;nbsp;arr[0...i-1]&amp;nbsp;is&amp;nbsp;sorted&amp;nbsp;in&amp;nbsp;every&amp;nbsp;iteration&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;key&amp;nbsp;which&amp;nbsp;we&amp;nbsp;will&amp;nbsp;inserting&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;point&amp;nbsp;to&amp;nbsp;last&amp;nbsp;element&amp;nbsp;of&amp;nbsp;sorted&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;shift&amp;nbsp;elements&amp;nbsp;greater&amp;nbsp;than&amp;nbsp;key&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;--;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;please&amp;nbsp;key&amp;nbsp;element&amp;nbsp;to&amp;nbsp;appropriate&amp;nbsp;please&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Driver&amp;nbsp;code:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[]&amp;nbsp;=&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;65&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;};&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;)&amp;nbsp;/&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;insertion_sort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;printing&amp;nbsp;sorted&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array:&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 19.8px; line-height: 26px; white-space: pre;&quot;&gt;&lt;div&gt;sorted&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;65&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Selection Sort:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h3&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;c++&amp;nbsp;implementation&amp;nbsp;of&amp;nbsp;selection&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;selection&amp;nbsp;sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;selection_sort&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[],&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;iterate&amp;nbsp;i&amp;nbsp;from&amp;nbsp;0&amp;nbsp;to&amp;nbsp;n-2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;consider&amp;nbsp;arr[i...n]&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_index&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;find&amp;nbsp;min&amp;nbsp;element&amp;nbsp;index&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_index&lt;/span&gt;]&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;])&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_index&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;swapping&amp;nbsp;min&amp;nbsp;element&amp;nbsp;with&amp;nbsp;first&amp;nbsp;element&amp;nbsp;for&amp;nbsp;array.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_index&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;min_index&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;}&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Driver&amp;nbsp;code:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[]&amp;nbsp;=&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;67895&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;99999&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;};&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;)&amp;nbsp;/&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;sizeof&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]);&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;selection_sort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;);&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;printing&amp;nbsp;sorted&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array:&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;}&lt;/div&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h3 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;sorted&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;font-size: 18px;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;23&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;67895&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;99999&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h2 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Merge Sort:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h3 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//c++&amp;nbsp;program&amp;nbsp;for&amp;nbsp;merge&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Merge&amp;nbsp;to&amp;nbsp;subarray&amp;nbsp;of&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;first_array&amp;nbsp;=&amp;nbsp;array[start..mid]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;second_array&amp;nbsp;=&amp;nbsp;array[mid+1..end]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Merge&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;creating&amp;nbsp;to&amp;nbsp;temp&amp;nbsp;subarray&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;copy&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;copy&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;index&amp;nbsp;reference&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;for&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;for&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;for&amp;nbsp;main&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_1&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;size&amp;nbsp;of&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_2&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;size&amp;nbsp;of&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;merge&amp;nbsp;subarray&amp;nbsp;first_array&amp;nbsp;and&amp;nbsp;second_array&amp;nbsp;into&amp;nbsp;array[start..end]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_1&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_2&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;copy&amp;nbsp;remaining&amp;nbsp;element&amp;nbsp;of&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;copy&amp;nbsp;remaining&amp;nbsp;element&amp;nbsp;of&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_2&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;main&amp;nbsp;merge&amp;nbsp;Sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;merge_sort&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;finding&amp;nbsp;mid&amp;nbsp;point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;&amp;nbsp;+&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;)&amp;nbsp;/&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;divide&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;merge_sort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;merge_sort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;conquer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Merge&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;driver&amp;nbsp;code&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;declaring&amp;nbsp;&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&amp;nbsp;=&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;78&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;};&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;merge_sort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;array&amp;nbsp;is&amp;nbsp;sorted&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array:&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h3 style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;sorted&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;78&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-color: white; color: #656565; font-size: 15px; font-style: italic; font-weight: 700;&quot;&gt;Read Also:&lt;/span&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/merge-sort.html&quot; style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #ff4545; font-size: 15px; font-style: italic; font-weight: 700; outline: 0px; padding: 0px; text-decoration-line: none; transition: color 0.17s ease 0s; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Merge Sort Algorithm&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Image of code:&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Bubble sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #202124; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpaIknyD72qMx0ahKJfnb9Xr777Xqb-UflW4pjwbs22uVn6ex75ohYE1opnHjvw3PB_Whi7ga8iTEOOnLk5zkGxGAn4EfkhdwkmgG6UGiL9vI-ZVXWbHKOT1gs2AqwtP74dtOyzjiD_E/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;bubble sort in cpp&quot; data-original-height=&quot;2238&quot; data-original-width=&quot;1200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpaIknyD72qMx0ahKJfnb9Xr777Xqb-UflW4pjwbs22uVn6ex75ohYE1opnHjvw3PB_Whi7ga8iTEOOnLk5zkGxGAn4EfkhdwkmgG6UGiL9vI-ZVXWbHKOT1gs2AqwtP74dtOyzjiD_E/s16000/image.png&quot; title=&quot;bubble sort in cpp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Insertion sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #202124; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_XtqCqdaGl0vFf9Y7O5Bhrfq_dbRNGggV01iCM56ZODsKN5LsdtYM137E9J6Aqc085TUq-W3OFwL8dbZcJ0Jpb69Ms6zjftfo31FILhc-nZtzeWiRAFaHGcoNdfesBom8LGg1UeyZ-Yw/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Insertion sort in cpp&quot; data-original-height=&quot;1896&quot; data-original-width=&quot;1030&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_XtqCqdaGl0vFf9Y7O5Bhrfq_dbRNGggV01iCM56ZODsKN5LsdtYM137E9J6Aqc085TUq-W3OFwL8dbZcJ0Jpb69Ms6zjftfo31FILhc-nZtzeWiRAFaHGcoNdfesBom8LGg1UeyZ-Yw/s16000/image.png&quot; title=&quot;Insertion sort in cpp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Selection sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #202124; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYEziW331CsauylgMDWifdieAuA1itSDGX_GOpNYXGyxNH70NLDdgg_Gm74huq320MSKxJ6mewFidR8JeG-ZSkOEAKV3rBEaMRCQNUHxiuLhsNaWyhdetvGAQCmsMNpWmSqww-i4Lgm-U/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Selection sort in cpp&quot; data-original-height=&quot;1896&quot; data-original-width=&quot;1108&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYEziW331CsauylgMDWifdieAuA1itSDGX_GOpNYXGyxNH70NLDdgg_Gm74huq320MSKxJ6mewFidR8JeG-ZSkOEAKV3rBEaMRCQNUHxiuLhsNaWyhdetvGAQCmsMNpWmSqww-i4Lgm-U/s16000/image.png&quot; title=&quot;Selection sort in cpp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #202124;&quot;&gt;&lt;b&gt;&lt;i&gt;Merge sort:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #202124; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMXYTpufvmDHUkP99OWQHezR8twHy4L_q4WJnyAtf6ZcKxRbknR-DAqowWx3jV4xBuWU3kbZPGz3-2LKMK4iAk6mzOSeJmmz54vmAP77-KD16SBVAjPpoJ5KMBXaC0TsTXCJ49Col2Yv8/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;merge sort in cpp&quot; data-original-height=&quot;3872&quot; data-original-width=&quot;1294&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMXYTpufvmDHUkP99OWQHezR8twHy4L_q4WJnyAtf6ZcKxRbknR-DAqowWx3jV4xBuWU3kbZPGz3-2LKMK4iAk6mzOSeJmmz54vmAP77-KD16SBVAjPpoJ5KMBXaC0TsTXCJ49Col2Yv8/s16000/image.png&quot; title=&quot;merge sort in cpp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/3961446754793717272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithms-in-cpp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3961446754793717272'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/3961446754793717272'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithms-in-cpp.html' title='All Sorting Algorithms Implementation In c++'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEi_PdT2GM5sYCZKQlSZP1tnfmTR4rATwFI50klkQWul-t2fcJ5NIRzKj3QCzECMdBhOoRjl4yz2IqtajfPiqOaZEjTQ2uEbC1n4C6Um4_ocWZXJvNirguVPSPmFknym4xF2VdIKGlstn_myy0T7MPuAptOP-caN7-0fCS5FD66R3HoUh7e4A1v7fny3=s72-w640-h360-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-8942815594474043379</id><published>2021-07-23T20:14:00.194+05:30</published><updated>2022-01-11T23:38:23.949+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="pascal&#39;s triangle"/><category scheme="http://www.blogger.com/atom/ns#" term="pattern"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Print N Rows of Pascal&#39;s Triangle in C++ and Python</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh8AC4-5y0S6PrjU1gNCJiHBvdJqvtMf29Rngv8Pvd7cJO4WeWs2VE2QINNxVL8anFATDPN6SUBx62Unow7K7DcMbEglANz7PVv7ECPLpn_hcUJAAxKeYRhHdZjD6rzq9aLq5kVjgkZv7JNCrppk7K79fpjFsvv4xqGP2lxy6yVrxntUKqL5KPVM322=s1733&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Pascal&#39;s Triangle in C++ and Python&quot; border=&quot;0&quot; data-original-height=&quot;1300&quot; data-original-width=&quot;1733&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEh8AC4-5y0S6PrjU1gNCJiHBvdJqvtMf29Rngv8Pvd7cJO4WeWs2VE2QINNxVL8anFATDPN6SUBx62Unow7K7DcMbEglANz7PVv7ECPLpn_hcUJAAxKeYRhHdZjD6rzq9aLq5kVjgkZv7JNCrppk7K79fpjFsvv4xqGP2lxy6yVrxntUKqL5KPVM322=w640-h480&quot; title=&quot;Pascal&#39;s Triangle in C++ and Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background-color: white; color: #4d5156;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-family: georgia; font-size: large;&quot;&gt;Pascal&#39;s triangle&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;background-color: white; color: #4d5156;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;b&gt;&lt;i&gt;Pascal&#39;s triangle&lt;/i&gt;&lt;/b&gt; is made up of a triangular array filled with &lt;i&gt;binomial coefficient&lt;/i&gt;s. binomial coefficients occur&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&amp;nbsp;in &lt;i&gt;binomial&amp;nbsp;expansion&lt;/i&gt;. the ith row of pascal&#39;s triangle represents coefficients of&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #4d5156; font-family: Consolas;&quot;&gt;&lt;i&gt;(a+b)^(i-1)&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt; binomial expansion coefficients.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjveh8A2B5rHrmuNILNU7_2E4EuTGYWKc5BM4nHoOnQhPX8neOXUmhEzE4kr7QN4OYiWddgj0eVkLu939tykuHFQYJWX6ZEgv7cfYUiuvOkucumebzCU1BIugzHpDfhv23f7p_sO6MeewQ/s248/Print+N+Rows+of+Pascal%2527s+triangle+in+C%252B%252B+and+Python.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Print N Rows of Pascal&#39;s triangle in C++ and Python&quot; border=&quot;0&quot; data-original-height=&quot;180&quot; data-original-width=&quot;248&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjveh8A2B5rHrmuNILNU7_2E4EuTGYWKc5BM4nHoOnQhPX8neOXUmhEzE4kr7QN4OYiWddgj0eVkLu939tykuHFQYJWX6ZEgv7cfYUiuvOkucumebzCU1BIugzHpDfhv23f7p_sO6MeewQ/s16000/Print+N+Rows+of+Pascal%2527s+triangle+in+C%252B%252B+and+Python.png&quot; title=&quot;Print N Rows of Pascal&#39;s triangle in C++ and Python&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;b&gt;7-row pascal&#39;s triangle.&lt;/b&gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&lt;b style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #202124; font-size: medium; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Read Also:&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-3d-array.html&quot; target=&quot;_blank&quot;&gt;Prefix Sum of 3D array&lt;/a&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&lt;i&gt;Example:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&lt;i&gt;Input:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt; N&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt; pascal&#39;s&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;triangle&lt;/span&gt;&amp;nbsp;of&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;Rows...&lt;/div&gt;&lt;div&gt; rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt; rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt; rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt; rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt; rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt; rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt; rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;15&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;20&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;15&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt; rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;21&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;35&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;35&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;21&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt; rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;28&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;56&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;70&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;56&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;28&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #4d5156; font-family: georgia;&quot;&gt;&lt;i&gt;Explanation:&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Create two &lt;/span&gt;&lt;i style=&quot;font-family: georgia;&quot;&gt;arrays &lt;/i&gt;&lt;b style=&quot;font-family: georgia;&quot;&gt;temp[]&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;with no element and &lt;/span&gt;&lt;b style=&quot;font-family: georgia;&quot;&gt;arr[]&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;with element equals to &lt;/span&gt;&lt;b style=&quot;font-family: georgia;&quot;&gt;1&lt;/b&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Iterate process &lt;/span&gt;&lt;b style=&quot;font-family: georgia;&quot;&gt;N &lt;/b&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;times for &lt;/span&gt;&lt;b style=&quot;font-family: georgia;&quot;&gt;N &lt;/b&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;rows.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: Consolas; font-size: medium;&quot;&gt;print &lt;i&gt;arr[]&lt;/i&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: Consolas; font-size: medium;&quot;&gt;Add 1 to back of &lt;i&gt;temp[]&lt;/i&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: Consolas; font-size: medium;&quot;&gt;Iterate form j = 0 to arr.size()-1 and add &lt;i&gt;arr[j]+arr[j+1]&lt;/i&gt; to back of &lt;i&gt;temp[].&lt;/i&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family: Consolas; font-size: medium;&quot;&gt;Add again 1 to back of &lt;i&gt;temp[]&lt;/i&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;this process print N rows of&amp;nbsp; Pascal&#39;s triangle.&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: large;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: large;&quot;&gt;&lt;i&gt;Implementation&lt;/i&gt;&lt;i&gt;:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;C++ Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 21.6px; line-height: 28px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;C++&amp;nbsp;code&amp;nbsp;for&amp;nbsp;Pascal&#39;s&amp;nbsp;Triangle&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;printPascal()&amp;nbsp;function&amp;nbsp;for&amp;nbsp;printing&amp;nbsp;pascal&#39;s&amp;nbsp;triangle.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;printPascal&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;N&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;declaring&amp;nbsp;2&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&amp;nbsp;=&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;};&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;current&amp;nbsp;row.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;pascal&#39;s&amp;nbsp;triangle&amp;nbsp;of&amp;nbsp;&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;N&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;Rows...&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;calculating&amp;nbsp;next&amp;nbsp;rows.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;N&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;printing&amp;nbsp;current&amp;nbsp;row.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;rows&amp;nbsp;&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;:&amp;nbsp;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;calculating&amp;nbsp;next&amp;nbsp;rows.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;()&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;copy&amp;nbsp;next&amp;nbsp;row&amp;nbsp;to&amp;nbsp;current&amp;nbsp;row.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;arr&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;initialize&amp;nbsp;temp&amp;nbsp;to&amp;nbsp;empty&amp;nbsp;array.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;temp&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Driver&amp;nbsp;code&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;N&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;printPascal&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;N&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;Python Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 21.6px; line-height: 28px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;python&amp;nbsp;code&amp;nbsp;for&amp;nbsp;Pascal&#39;s&amp;nbsp;Triangle&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;printPascal()&amp;nbsp;function&amp;nbsp;for&amp;nbsp;printing&amp;nbsp;pascal&#39;s&amp;nbsp;triangle.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;printPascal&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;N&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;declaring&amp;nbsp;2&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arr&amp;nbsp;=&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;temp&amp;nbsp;=&amp;nbsp;[]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;pascal&#39;s&amp;nbsp;triangle&amp;nbsp;of&quot;&lt;/span&gt;,&amp;nbsp;N,&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Rows...&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;calculating&amp;nbsp;next&amp;nbsp;rows.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(N):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;printing&amp;nbsp;current&amp;nbsp;row.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;rows&quot;&lt;/span&gt;,&amp;nbsp;i+&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;:&amp;nbsp;&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(arr)):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(arr[j],&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;calculating&amp;nbsp;next&amp;nbsp;rows.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;temp.append(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(arr)-&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;temp.append(arr[j]&amp;nbsp;+&amp;nbsp;arr[j&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;temp.append(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;copy&amp;nbsp;next&amp;nbsp;row&amp;nbsp;to&amp;nbsp;current&amp;nbsp;row.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arr&amp;nbsp;=&amp;nbsp;temp&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;initialize&amp;nbsp;temp&amp;nbsp;to&amp;nbsp;empty&amp;nbsp;array.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;temp&amp;nbsp;=&amp;nbsp;[]&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Driver&amp;nbsp;code&lt;/span&gt;&lt;/div&gt;&lt;div&gt;N&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&lt;/div&gt;&lt;div&gt;printPascal(N)&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 21.6px; line-height: 28px; white-space: pre;&quot;&gt;&lt;div&gt;pascal&#39;s&amp;nbsp;triangle&amp;nbsp;of&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;Rows...&lt;/div&gt;&lt;div&gt;rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;15&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;20&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;15&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;21&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;35&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;35&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;21&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;7&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;rows&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;28&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;56&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;70&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;56&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;28&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span face=&quot;urw-din, sans-serif&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: #273239; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;i style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Time Complexity&lt;/strong&gt;:&lt;/i&gt;&amp;nbsp;O(N^2) &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #d4d4d4; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span face=&quot;urw-din, sans-serif&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: #273239; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;i style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Auxiliary Space&lt;/strong&gt;:&amp;nbsp;&lt;/i&gt;O(N)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;b style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #202124; font-size: medium; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Read Also:&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-2d-array.html&quot; target=&quot;_blank&quot;&gt;Prefix Sum of 2D Array&lt;/a&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/8942815594474043379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/print-n-rows-of-pascals-triangle-in-cpp-and-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8942815594474043379'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8942815594474043379'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/print-n-rows-of-pascals-triangle-in-cpp-and-python.html' title='Print N Rows of Pascal&#39;s Triangle in C++ and Python'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEh8AC4-5y0S6PrjU1gNCJiHBvdJqvtMf29Rngv8Pvd7cJO4WeWs2VE2QINNxVL8anFATDPN6SUBx62Unow7K7DcMbEglANz7PVv7ECPLpn_hcUJAAxKeYRhHdZjD6rzq9aLq5kVjgkZv7JNCrppk7K79fpjFsvv4xqGP2lxy6yVrxntUKqL5KPVM322=s72-w640-h480-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>20.593653454562304 78.962846472387312 20.593714545437695 78.962913527612685</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-7663710105436729448</id><published>2021-07-21T12:45:00.008+05:30</published><updated>2022-01-11T23:40:33.265+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="prefix sum"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Prefix Sum For Array (Cumulative Sum)</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWG_YP-BRI4PA_ti5zd3JnDO_xwnUX3eXzqTZep9f77hDRj0-ctYrhujMcziRN2nX066jcvcVnQPy_g6l04eeRzNXTXO95rDLKlJdX7hebeI25y_rOv6gZGqueFwJPsSsVqRBzoONBqXs/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Prefix Sum For Array (Cumulative Sum)&quot; data-original-height=&quot;1253&quot; data-original-width=&quot;1880&quot; height=&quot;426&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWG_YP-BRI4PA_ti5zd3JnDO_xwnUX3eXzqTZep9f77hDRj0-ctYrhujMcziRN2nX066jcvcVnQPy_g6l04eeRzNXTXO95rDLKlJdX7hebeI25y_rOv6gZGqueFwJPsSsVqRBzoONBqXs/w640-h426/image.png&quot; title=&quot;Prefix Sum For Array (Cumulative Sum)&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-size: 16pt; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Use:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-size: 11pt; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;The &lt;b&gt;&lt;i&gt;prefix sum&lt;/i&gt;&lt;/b&gt; algorithm is very popular and also used in &lt;b&gt;competitive programming&lt;/b&gt;. Mostly used in &lt;b&gt;subarray sum&lt;/b&gt; find in constant time.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;b id=&quot;docs-internal-guid-7dc925b8-7fff-a41c-482b-8534030e30da&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Problem:&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-size: 11pt; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt;Given an &lt;/span&gt;&lt;span style=&quot;font-family: georgia; font-style: normal;&quot;&gt;&lt;b&gt;array &lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt;of integers &lt;/span&gt;&lt;span style=&quot;font-family: Source Code Pro; font-style: normal;&quot;&gt;&lt;b&gt;array[L]&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt;, where &lt;/span&gt;&lt;b style=&quot;font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;L &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt;is the &lt;/span&gt;&lt;span style=&quot;font-family: georgia; font-style: normal;&quot;&gt;&lt;b&gt;length &lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt;of the array.&amp;nbsp; you have to compute the &lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;b&gt;&lt;i&gt;prefix sum&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: georgia; font-weight: 400;&quot;&gt;&lt;i&gt; &lt;/i&gt;(prefix array) &lt;/span&gt;&lt;b style=&quot;font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[L]&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt; of &lt;/span&gt;&lt;b style=&quot;font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;array[L]&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt;. where &lt;/span&gt;&lt;b style=&quot;font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[i] &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt;represents the sum of all cells between &lt;/span&gt;&lt;b style=&quot;font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;array[0]&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt; to&lt;/span&gt;&lt;b style=&quot;font-style: normal;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt; array[i] &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: georgia; font-style: normal; font-weight: 400;&quot;&gt;inclusively.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-size: 16pt; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Example:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #434343; font-size: 14pt; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Input:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array = {&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;};&lt;/span&gt;&lt;/p&gt;&lt;h3 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #434343; font-size: 14pt; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefix Sum is:&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;21&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;28&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-size: 16pt; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: georgia; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;First of all, fill the first element of the array as it is.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: georgia; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;Then iterate through 1 to L in the array and add the previous element of &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-size: 11pt; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;prefix[]&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: georgia; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; to the coronet element using this formula.&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-size: 16pt; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Formula:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefix&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; + &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefix&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; - &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;h2 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 6pt; margin-top: 18pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-size: 16pt; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #434343; font-size: 14pt; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;C++ implementation:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;// C++ program for prefix sum of array&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #ce9178; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;namespace&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #4ec9b0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;std&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;// computing prefix sum&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefixSum&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #4ec9b0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;();&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #4ec9b0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefix&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// copy first element of array&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefix&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// previous element to the coronet element&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &amp;lt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;++)&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefix&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; + &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefix&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; - &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;cout&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #ce9178; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&quot;prefix Sum is:&quot;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;endl&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &amp;lt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;++)&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;cout&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefix&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #ce9178; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;cout&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;endl&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;// Driver code&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;()&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #4ec9b0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; = {&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;};&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefixSum&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h3 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;&quot;&gt;&lt;i style=&quot;color: #434343; font-family: georgia; font-size: 14pt; font-weight: 400; white-space: pre-wrap;&quot;&gt;Python implementation:&lt;/i&gt;&lt;/h3&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;# python program for prefix sum of array&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;# computing prefix sum&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #569cd6; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefixSum&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;):&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;L = &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;len&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(array)&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix = [&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(L)]&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;# copy the first element.&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;] = array[&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;# previous element to the coronet element&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, L):&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[i] = array[i] + prefix[i - &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;# Display prefix sum.&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #ce9178; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&quot;prefix Sum is:&quot;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #c586c0; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;range&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(L):&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;(prefix[i], &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #9cdcfe; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;end&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #ce9178; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&#39; &#39;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #dcdcaa; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;print&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;()&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #6a9955; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;# Driver code&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;array = [&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;]&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefixSum(array)&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h3 dir=&quot;ltr&quot; style=&quot;line-height: 1.38; margin-bottom: 4pt; margin-top: 16pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #434343; font-size: 14pt; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;prefix Sum is:&lt;/span&gt;&lt;/p&gt;&lt;p dir=&quot;ltr&quot; style=&quot;background-color: #1e1e1e; line-height: 1.6; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;21&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #d4d4d4; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #b5cea8; font-family: &#39;Courier New&#39;; font-size: 13.5pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;&quot;&gt;28&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background: 0px 0px white; border: 0px; box-sizing: border-box; color: #273239; font-family: georgia; font-size: 17px; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i&gt;&lt;strong style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Time Complexity&lt;/strong&gt;: &lt;/i&gt;O(L) &amp;nbsp;&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;background: 0px 0px white; border: 0px; box-sizing: border-box; color: #273239; font-family: georgia; font-size: 17px; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i&gt;&lt;strong style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Auxiliary Space&lt;/strong&gt;:&lt;/i&gt; &lt;b&gt;O(L)&lt;/b&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background: 0px 0px white; border: 0px; box-sizing: border-box; color: #273239; font-family: georgia; font-size: 17px; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;where L is the length of the array.&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;i&gt;Read more interesting articles on prefix sum:&lt;/i&gt;&lt;/h3&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-2d-array.html&quot;&gt;Prefix Sum for 2D Array&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-3d-array.html&quot; target=&quot;_blank&quot;&gt;Prefix Sum for 3D Array&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/h4&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/7663710105436729448/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-one-dimensional-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/7663710105436729448'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/7663710105436729448'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-one-dimensional-array.html' title='Prefix Sum For Array (Cumulative Sum)'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWG_YP-BRI4PA_ti5zd3JnDO_xwnUX3eXzqTZep9f77hDRj0-ctYrhujMcziRN2nX066jcvcVnQPy_g6l04eeRzNXTXO95rDLKlJdX7hebeI25y_rOv6gZGqueFwJPsSsVqRBzoONBqXs/s72-w640-h426-c/image.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-1261529312383489745</id><published>2021-07-19T19:55:00.020+05:30</published><updated>2023-06-28T12:23:38.246+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="2d"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="prefix sum"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Prefix Sum For 2D Array (Prefix Sum Of Matrix)</title><content type='html'>
&lt;h1 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 15px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;h1 dir=&quot;ltr&quot; style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 24px; font-weight: 500; line-height: 1.38; margin: 20pt 0px 6pt; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px transparent; border: 0px; color: black; font-size: 20pt; font-variant-east-asian: normal; font-variant-numeric: normal; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Prefix Sum For 2D Array - Compute Prefix Sum For two Dimensional Array(Prefix Sum Of Matrix).&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h1&gt;&lt;p&gt;&lt;span&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;Given a &lt;i&gt;2&lt;/i&gt;&lt;/span&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-family: georgia; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i&gt;-Dimensional array&lt;/i&gt;&lt;/strong&gt;&lt;span style=&quot;background-color: white; font-size: 15px;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&amp;nbsp;of integers &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;array[R][C]&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;, where&lt;/span&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-family: georgia; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;/strong&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;R&lt;/strong&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;and&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;C&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;are dimensions of the array (Row and Column). Find&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-family: georgia; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;prefix sum&lt;/strong&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;&amp;nbsp;2d array for it.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;Let Prefix sum 3d array be&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[R][C]&lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;.&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;Here&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[i][j]&lt;/span&gt;&lt;/strong&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-family: georgia; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;/strong&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;&amp;nbsp;gives sum of all integers between&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[0][0]&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[i][j]&lt;/span&gt;&lt;/strong&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-family: georgia; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;/strong&gt;&lt;span style=&quot;background-color: white; font-family: georgia; font-size: 15px;&quot;&gt;(including both).&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: large;&quot;&gt;&lt;i&gt;Example:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: large;&quot;&gt;&lt;i&gt;Input:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;div style=&quot;line-height: 24px;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}};&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 18px; white-space: pre;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;given 4x4 size &lt;i&gt;2-&lt;/i&gt;&lt;/span&gt;&lt;strong style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;i&gt;Dimensional&amp;nbsp; array&lt;/i&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left; white-space: pre;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;white-space: pre;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px;&quot;&gt;&lt;div&gt;prefix&amp;nbsp;sum&amp;nbsp;is:&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;18&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;32&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;white-space: pre;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfgkqTLloFh9pna9CzAddWaum7KwTi63ffNjK36k-5L8Hluy1_gYPcpeesBWIdaXnf0MniQ5E7sJt_yeVOi6NvMP8NhNUVQaPoxgS_bbBbsegeFYl35hweG68b0g5LsKe8f-VJrkxr7QU/s918/prefixsum2d.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Prefix Sum For 2d Array&quot; border=&quot;0&quot; data-original-height=&quot;749&quot; data-original-width=&quot;918&quot; height=&quot;326&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfgkqTLloFh9pna9CzAddWaum7KwTi63ffNjK36k-5L8Hluy1_gYPcpeesBWIdaXnf0MniQ5E7sJt_yeVOi6NvMP8NhNUVQaPoxgS_bbBbsegeFYl35hweG68b0g5LsKe8f-VJrkxr7QU/w400-h326/prefixsum2d.png&quot; title=&quot;Prefix Sum For 2d Array&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;h3 style=&quot;clear: both; text-align: center;&quot;&gt;Image for formula creation.&lt;/h3&gt;&lt;br /&gt;&lt;span style=&quot;font-family: georgia; font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;white-space: pre;&quot;&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: large;&quot;&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;Explanation of formula:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;p&gt;&lt;span&gt;&lt;span style=&quot;background-color: initial; font-family: georgia; font-size: 15px;&quot;&gt;Consider the above image for the formula explanation. if we want to find prefix sum value in a white cell, we have to add the prefix sum of neighbor orange cells and subtract red cells to remove overlappings.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;i&gt;Step 0:&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Fill &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;array[0]&lt;/span&gt;&lt;/b&gt; &lt;span style=&quot;font-family: georgia;&quot;&gt;= &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[0]&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: small;&quot;&gt;&lt;b&gt;&lt;i&gt;Step 1:&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;Fill first row and column using prefix sum for 1d array.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;span style=&quot;background-color: white; color: #656565;&quot;&gt;check this here for 1d prefix sum:&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-one-dimensional-array.html&quot; style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #ff4545; outline: 0px; padding: 0px; text-decoration-line: none; transition: color 0.17s ease 0s; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;prefix sum for 1d array&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;i&gt;Step 2:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;Fill all remaining cells using the formula discussed above.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;i&gt;Formula:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[i][j]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[i][j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;i style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: georgia; font-size: 16pt; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: georgia; font-size: 16pt; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Implementation:&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: georgia; font-size: 16pt; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span&gt;&lt;h3 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; font-family: Nunito, sans-serif; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; font-size: small; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;C++ Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-size: 15px; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;C++&amp;nbsp;Program&amp;nbsp;to&amp;nbsp;find&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;2d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Declaring&amp;nbsp;size&amp;nbsp;of&amp;nbsp;the&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Rows&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;Columns&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Calculating&amp;nbsp;prefix&amp;nbsp;sum&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;prefixSum2d&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;0:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;1:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;first&amp;nbsp;row&amp;nbsp;and&amp;nbsp;column&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;for&amp;nbsp;1d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;2:&amp;nbsp;Filling&amp;nbsp;value&amp;nbsp;in&amp;nbsp;remaining&amp;nbsp;cells&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;using&amp;nbsp;formula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Displaying&amp;nbsp;final&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;prefix&amp;nbsp;sum&amp;nbsp;is:&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #d7ba7d;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Driver&amp;nbsp;program&amp;nbsp;to&amp;nbsp;test&amp;nbsp;above&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;prefixSum2d&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiusgt60QiWzvKTDF4IVZ9B1DWiI87OJ_hwfflOLkrQVbWZlpst4uNwQqK49b00UFSixzXaNi8d1mKWp9o_SFeCSrKDzBZD0uzLlMCS0BnuGMA6hpF_7N7maCdu7Lt6ycrEA2RXtPrGz2M/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;2d prefix sum in cpp&quot; data-original-height=&quot;2276&quot; data-original-width=&quot;986&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiusgt60QiWzvKTDF4IVZ9B1DWiI87OJ_hwfflOLkrQVbWZlpst4uNwQqK49b00UFSixzXaNi8d1mKWp9o_SFeCSrKDzBZD0uzLlMCS0BnuGMA6hpF_7N7maCdu7Lt6ycrEA2RXtPrGz2M/s16000/image.png&quot; title=&quot;2d prefix sum in cpp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Python&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Implementation:&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;python&amp;nbsp;Program&amp;nbsp;to&amp;nbsp;find&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;2d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Declaring&amp;nbsp;size&amp;nbsp;of&amp;nbsp;the&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;R&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Rows&lt;/span&gt;&lt;/div&gt;&lt;div&gt;C&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Columns&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Calculating&amp;nbsp;prefix&amp;nbsp;sum&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;prefixSum2d&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix&amp;nbsp;=&amp;nbsp;[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(R)]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(C)]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Step&amp;nbsp;0:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;array[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Step&amp;nbsp;1:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;first&amp;nbsp;row&amp;nbsp;and&amp;nbsp;column&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;for&amp;nbsp;1d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i]&amp;nbsp;=&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;array[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;prefix[i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;array[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Step&amp;nbsp;2:&amp;nbsp;Filling&amp;nbsp;value&amp;nbsp;in&amp;nbsp;remaining&amp;nbsp;cells&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;using&amp;nbsp;formula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[i][j]&amp;nbsp;=&amp;nbsp;(array[i][j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;prefix[i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;prefix[i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;prefix[i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Displaying&amp;nbsp;final&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;prefix&amp;nbsp;sum&amp;nbsp;is:&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(C):&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(prefix[i][j],&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Driver&amp;nbsp;program&amp;nbsp;to&amp;nbsp;test&amp;nbsp;above&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;array&amp;nbsp;=&amp;nbsp;[&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;prefixSum2d(array)&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;&lt;i style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-size: large; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;&lt;i style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-size: large; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZaaisQ5BfVWPkTK9pfgFi7EKuVKWOsUupfLNx4ft-zVvv0Sf6u_VCzH1lH0zwEXkrm-SFhxvQKmj9T56xgiQZfTocbRFrNA8mOd6NWvxHcbuScFbamMw1qHivjZsSTyqgk-qL_bnEFrk/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;2d prefix sum in python&quot; data-original-height=&quot;1896&quot; data-original-width=&quot;970&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZaaisQ5BfVWPkTK9pfgFi7EKuVKWOsUupfLNx4ft-zVvv0Sf6u_VCzH1lH0zwEXkrm-SFhxvQKmj9T56xgiQZfTocbRFrNA8mOd6NWvxHcbuScFbamMw1qHivjZsSTyqgk-qL_bnEFrk/s16000/image.png&quot; title=&quot;2d prefix sum in python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;&lt;i style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-size: large; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;&lt;i style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-size: large; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Output:&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; font-size: medium; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-size: 16pt; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #d4d4d4; font-family: Roboto, sans-serif; font-size: 18px; font-style: normal; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;h2 style=&quot;background: 0px 0px; border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 24px; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span face=&quot;urw-din, sans-serif&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: #273239; font-size: 17px; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; font-weight: normal; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;prefix&amp;nbsp;sum&amp;nbsp;is:&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;18&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;32&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/strong&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;background: 0px 0px; border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 24px; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span face=&quot;urw-din, sans-serif&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: #273239; font-size: 17px; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Time Complexity&lt;/strong&gt;:&lt;/i&gt;&amp;nbsp;O(R*C) &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span face=&quot;urw-din, sans-serif&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: #273239; font-size: 17px; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;background: 0px 0px; border: 0px; box-sizing: border-box; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Auxiliary Space&lt;/strong&gt;:&amp;nbsp;&lt;/i&gt;O(R*C)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #d4d4d4; font-family: Roboto, sans-serif; font-size: 18px; font-style: normal; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span face=&quot;urw-din, sans-serif&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: #273239; font-size: 17px; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #d4d4d4; font-family: Roboto, sans-serif; font-size: 18px; font-style: normal; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span face=&quot;urw-din, sans-serif&quot; style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; box-sizing: border-box; color: #273239; font-size: 17px; letter-spacing: 0.162px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;Read more:&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #656565; font-family: Roboto, sans-serif; font-size: 18px; font-style: normal; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-size: 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;check this here for 3D prefix sum:&lt;span style=&quot;background: 0px 0px; border: 0px; color: #ffa400; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-3d-array.html&quot; style=&quot;background: 0px 0px; border: 0px; color: #ff4545; outline: 0px; padding: 0px; text-decoration-line: none; transition: color 0.17s ease 0s; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; color: #e69138; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;prefix sum for 3D array&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;Find the type of Quadrilateral with given 4 points of the quadrilateral &lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/find-type-of-quadrilateral-with-given-points.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/hangman-game-using-python-and-c.html&quot; target=&quot;_blank&quot;&gt;Hangman game in cpp and python&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/prove-numpy-is-faster-than-normal-list.html&quot; target=&quot;_blank&quot;&gt;Prove numpy is faster than normal list&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15px;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; font-size: medium; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-size: 16pt; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/1261529312383489745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-2d-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/1261529312383489745'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/1261529312383489745'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-2d-array.html' title='Prefix Sum For 2D Array (Prefix Sum Of Matrix)'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfgkqTLloFh9pna9CzAddWaum7KwTi63ffNjK36k-5L8Hluy1_gYPcpeesBWIdaXnf0MniQ5E7sJt_yeVOi6NvMP8NhNUVQaPoxgS_bbBbsegeFYl35hweG68b0g5LsKe8f-VJrkxr7QU/s72-w400-h326-c/prefixsum2d.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165518848024206 43.806627317790984 48.90391988480242 114.11913268220901</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-8032836449479683342</id><published>2021-07-18T19:02:00.013+05:30</published><updated>2022-08-28T12:57:24.350+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="3d"/><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="prefix sum"/><title type='text'>Prefix Sum for 3D Array (Cumulative Sum For Three Dimensional Array).</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjOMeSp-kIny4EH2gFPfnsP_eodfIgDzKO3mF3CvrmHfA4g1qsOrq08fYLhbbgjB1AIBdJfOdyJfig5DM_Fb4h6ZRWyWeUvOiItdy9tZByndCFHBeWpHhrqGw6VUtRxm8QdhnT2JqfNL-Ydy2qnzLGnXm-lQDBh3MGvOEUirJ-mbHUFEe6Q2edtvrT4=s1792&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Prefix Sum for 3D Array (Cumulative Sum For Three Dimensional Array).&quot; border=&quot;0&quot; data-original-height=&quot;1300&quot; data-original-width=&quot;1792&quot; height=&quot;464&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjOMeSp-kIny4EH2gFPfnsP_eodfIgDzKO3mF3CvrmHfA4g1qsOrq08fYLhbbgjB1AIBdJfOdyJfig5DM_Fb4h6ZRWyWeUvOiItdy9tZByndCFHBeWpHhrqGw6VUtRxm8QdhnT2JqfNL-Ydy2qnzLGnXm-lQDBh3MGvOEUirJ-mbHUFEe6Q2edtvrT4=w640-h464&quot; title=&quot;Prefix Sum for 3D Array (Cumulative Sum For Three Dimensional Array).&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Given a &lt;i&gt;&lt;strong&gt;3-Dimensional array&lt;/strong&gt; &lt;/i&gt;of integers &lt;strong&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;A[L][R][C]&lt;/span&gt;&lt;/strong&gt;, where&lt;strong&gt; &lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;L, R&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;,&lt;/span&gt;&lt;strong&gt; &lt;/strong&gt;and &lt;strong&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;C &lt;/span&gt;&lt;/strong&gt;are dimensions of the array (Layer, Row, Column). Find &lt;strong&gt;&lt;i&gt;prefix sum&lt;/i&gt;&lt;/strong&gt; 3d array for it.&lt;/p&gt;&lt;p&gt;Let Prefix sum 3d array be &lt;strong&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[L][R][C]&lt;/span&gt;. &lt;/strong&gt;Here &lt;strong&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[k][i][j]&lt;/span&gt;&amp;nbsp;&lt;/strong&gt; gives sum of all integers between &lt;strong&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[0][0]&lt;/span&gt;[0]&lt;/strong&gt; and &lt;strong&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;prefix[k][i][j]&lt;/span&gt; &lt;/strong&gt;(including both).&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Example:&lt;/span&gt;&lt;/i&gt;&lt;/h2&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Input:&lt;/span&gt;&lt;/i&gt;&lt;/h3&gt;&lt;div&gt;&lt;div style=&quot;line-height: 24px;&quot;&gt;&lt;div style=&quot;line-height: 24px;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Layer&amp;nbsp;1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Layer&amp;nbsp;2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Layer&amp;nbsp;3&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Layer&amp;nbsp;4&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}}&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left; white-space: pre;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: small;&quot;&gt;&lt;i&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;white-space: pre;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-size: 18px; line-height: 24px;&quot;&gt;&lt;div&gt;Layer&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;18&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;32&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Consolas, Courier New, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;Layer&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;32&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;36&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;48&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;32&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;48&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;64&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Consolas, Courier New, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;Layer&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;18&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;36&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;48&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;18&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;36&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;54&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;72&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;48&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;72&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;96&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-family: Consolas, Courier New, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;Layer&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;8&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;32&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;32&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;48&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;64&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;48&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;72&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;96&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;32&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;64&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;96&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;128&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: 18px; white-space: pre;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;h3 style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; text-align: left; white-space: pre;&quot;&gt;&lt;strong&gt;&lt;i&gt;Step 0:&amp;nbsp;&lt;/i&gt;&lt;/strong&gt;&lt;/h3&gt;&lt;p style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Element at (0,0,0) is directly filled.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;&lt;b&gt;prefix[0][0][0] = array[0][0][0]&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; text-align: left; white-space: pre;&quot;&gt;&lt;strong&gt;&lt;i&gt;Step 1:&lt;/i&gt;&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium; white-space: normal;&quot;&gt;&amp;nbsp;&lt;/span&gt;Fill cells of three edges (parallel to x, y, z-axis and made up using cells) using prefix sum on the one-dimensional array.&amp;nbsp;&lt;/p&gt;&lt;p&gt;check this article for 1d prefix sum:&amp;nbsp;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-one-dimensional-array.html&quot; target=&quot;_blank&quot;&gt;prefix sum for 1d array&lt;/a&gt;&lt;/p&gt;&lt;p&gt;These edges have common element &lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;&lt;b&gt;prefix[0][0][0].&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; text-align: left; white-space: pre;&quot;&gt;&lt;strong&gt;&lt;i&gt;Step 2:&lt;/i&gt;&lt;/strong&gt;&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium; white-space: normal;&quot;&gt;&amp;nbsp;&lt;/span&gt;Fill cells of three sides (parallel to xy, yz, zx-plane and made up using cells) using prefix sum on the two-dimensional array.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;check this article for 2d prefix sum: &lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-2d-array.html&quot; target=&quot;_blank&quot;&gt;prefix sum for 2d array&lt;/a&gt;&lt;/p&gt;&lt;p&gt;These sides have common element &lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;&lt;b&gt;prefix[0][0][0].&lt;span style=&quot;font-size: medium; white-space: normal;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3 style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; text-align: left; white-space: pre;&quot;&gt;&lt;strong&gt;&lt;i&gt;Step 3:&lt;/i&gt;&lt;/strong&gt;&lt;/h3&gt;&lt;p style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Fill all remaining cells using the general formula.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[k][i][j]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[k][i][j]&amp;nbsp;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i][j]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[k][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[k][i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[k][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 18px; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Implimentation:&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 18px; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;C++ Implimentation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;C++&amp;nbsp;program&amp;nbsp;to&amp;nbsp;calculate&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;3d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Declaring&amp;nbsp;size&amp;nbsp;of&amp;nbsp;the&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Layer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Row&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#define&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Column&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Calculating&amp;nbsp;prefix&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;prefixSum3d&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;1:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;first&amp;nbsp;row,column,&amp;nbsp;and&amp;nbsp;pile&amp;nbsp;of&amp;nbsp;ceils.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;1d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;L;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;];&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;2:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;cells&amp;nbsp;of&amp;nbsp;sides(made&amp;nbsp;up&amp;nbsp;using&amp;nbsp;cells)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;which&amp;nbsp;have&amp;nbsp;common&amp;nbsp;element&amp;nbsp;array[0][0][0].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;on&amp;nbsp;2d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;L;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;L;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Step&amp;nbsp;3:&amp;nbsp;Filling&amp;nbsp;value&amp;nbsp;in&amp;nbsp;remaining&amp;nbsp;cells&amp;nbsp;using&amp;nbsp;formula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;L;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;Displaying&amp;nbsp;final&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;prefix&amp;nbsp;sum&amp;nbsp;is:&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;L;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Layer&amp;nbsp;&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;:&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;R;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;C;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;prefix&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;][&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Driver&amp;nbsp;program&amp;nbsp;to&amp;nbsp;test&amp;nbsp;above&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #569cd6;&quot;&gt;L&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;R&lt;/span&gt;][&lt;span style=&quot;color: #569cd6;&quot;&gt;C&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Layer&amp;nbsp;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Layer&amp;nbsp;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Layer&amp;nbsp;3&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//Layer&amp;nbsp;4&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;},&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;}}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;prefixSum3d&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;h3 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 18px; font-style: normal; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhIUB0drTIYQ_aFNWFpaZTEF-t7fix9wbskIbPZXIJZhVQsTNsxs6MPeU0BgQCQRV427e2Ce7q2CRok_cq-d0Us420TzktYEVr-lP-vuO6wNCrekZF5tH4Qa2c9-mLacK5LC1er193CC6XatlAKIJfHclA1v7WdctPYrqyQoDi92Gl0474yQot8WYrs=s4898&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;3d prefix sum in cpp&quot; border=&quot;0&quot; data-original-height=&quot;4898&quot; data-original-width=&quot;1138&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhIUB0drTIYQ_aFNWFpaZTEF-t7fix9wbskIbPZXIJZhVQsTNsxs6MPeU0BgQCQRV427e2Ce7q2CRok_cq-d0Us420TzktYEVr-lP-vuO6wNCrekZF5tH4Qa2c9-mLacK5LC1er193CC6XatlAKIJfHclA1v7WdctPYrqyQoDi92Gl0474yQot8WYrs=s16000&quot; title=&quot;3d prefix sum in cpp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 18px; font-style: normal; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;python code for it:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;python&amp;nbsp;program&amp;nbsp;to&amp;nbsp;calculate&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;3d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Declaring&amp;nbsp;size&amp;nbsp;of&amp;nbsp;the&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;L&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;R&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Row&lt;/span&gt;&lt;/div&gt;&lt;div&gt;C&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Column&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Calculating&amp;nbsp;prefix&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;prefixSum3d&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;):&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix&amp;nbsp;=&amp;nbsp;[[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(C)]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(R)]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;d&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(L)]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;array[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Step&amp;nbsp;1:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;first&amp;nbsp;row,column,&amp;nbsp;and&amp;nbsp;pile&amp;nbsp;of&amp;nbsp;ceils.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;1d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;L):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;prefix[i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;array[i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;array[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i]&amp;nbsp;=&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;array[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Step&amp;nbsp;2:&amp;nbsp;Filling&amp;nbsp;the&amp;nbsp;cells&amp;nbsp;of&amp;nbsp;sides(made&amp;nbsp;up&amp;nbsp;using&amp;nbsp;cells)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;which&amp;nbsp;have&amp;nbsp;common&amp;nbsp;element&amp;nbsp;A[0][0][0].&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;using&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;on&amp;nbsp;2d&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;L):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[k][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;(array[k][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;prefix[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&amp;nbsp;+&amp;nbsp;prefix[k][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;prefix[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][j]&amp;nbsp;=&amp;nbsp;(array[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][j]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&amp;nbsp;+&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;prefix[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;L):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[k][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j]&amp;nbsp;=&amp;nbsp;(array[k][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j]&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;prefix[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j]&amp;nbsp;+&amp;nbsp;prefix[k][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;prefix[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Step&amp;nbsp;3:&amp;nbsp;Filling&amp;nbsp;value&amp;nbsp;in&amp;nbsp;remaining&amp;nbsp;cells&amp;nbsp;using&amp;nbsp;formula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;L):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;prefix[k][i][j]&amp;nbsp;=&amp;nbsp;(array[k][i][j]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;prefix[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i][j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;prefix[k][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;prefix[k][i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;prefix[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;prefix[k][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;prefix[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+&amp;nbsp;prefix[k&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][i&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Displaying&amp;nbsp;final&amp;nbsp;prefix&amp;nbsp;sum&amp;nbsp;of&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;prefix&amp;nbsp;sum&amp;nbsp;is:&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(L):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Layer&quot;&lt;/span&gt;,&amp;nbsp;k+&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;:&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(R):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(C):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(prefix[k][i][j],&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Driver&amp;nbsp;program&amp;nbsp;to&amp;nbsp;test&amp;nbsp;above&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;array&amp;nbsp;=&amp;nbsp;[&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&amp;nbsp;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;]],&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&amp;nbsp;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;]],&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&amp;nbsp;3&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;]],&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Layer&amp;nbsp;4&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;],&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;]]&lt;/div&gt;&lt;div&gt;]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;prefixSum3d(array)&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 24px; font-style: normal; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; font-size: medium; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/i&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 24px; font-style: normal; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; font-size: medium; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhtJAyRSJjxXyfzOVrIapA-whEOGSqUwwo29KhmW255n4EGiLMW6Nf3cf5CRoTvtMFfLYjM5V4UlARzxR2s8J8MWjwN8h3cr3zCSM5Cykt3A9PFvzHD9z_fjSOJFByz0p1xrx6fOJdn8ITkjxJ8yH-N-4vrOJBYCCwicSBouqJ2D3j1GjWrWMi7WE6H=s3872&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;3d prefix sum python&quot; border=&quot;0&quot; data-original-height=&quot;3872&quot; data-original-width=&quot;1170&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhtJAyRSJjxXyfzOVrIapA-whEOGSqUwwo29KhmW255n4EGiLMW6Nf3cf5CRoTvtMFfLYjM5V4UlARzxR2s8J8MWjwN8h3cr3zCSM5Cykt3A9PFvzHD9z_fjSOJFByz0p1xrx6fOJdn8ITkjxJ8yH-N-4vrOJBYCCwicSBouqJ2D3j1GjWrWMi7WE6H=s16000&quot; title=&quot;3d prefix sum python&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/i&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 24px; font-style: normal; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; font-size: medium; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Time Complexity&lt;/i&gt;&lt;/strong&gt;: O(L*R*C) &amp;nbsp;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; font-family: Nunito, sans-serif; font-size: 18px; font-style: normal; font-weight: 500; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;strong style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Auxiliary Space&lt;/i&gt;&lt;/strong&gt;: O(L*R*C)&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;div style=&quot;background-color: #f7faff; font-size: 18px; font-style: normal;&quot;&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;Find the type of Quadrilateral with given 4 points of the quadrilateral&amp;nbsp;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2022/01/find-type-of-quadrilateral-with-given-points.html&quot; style=&quot;background: transparent; color: #25a142; cursor: pointer; text-decoration-line: none;&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/8032836449479683342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-3d-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8032836449479683342'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8032836449479683342'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/prefix-sum-for-3d-array.html' title='Prefix Sum for 3D Array (Cumulative Sum For Three Dimensional Array).'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEjOMeSp-kIny4EH2gFPfnsP_eodfIgDzKO3mF3CvrmHfA4g1qsOrq08fYLhbbgjB1AIBdJfOdyJfig5DM_Fb4h6ZRWyWeUvOiItdy9tZByndCFHBeWpHhrqGw6VUtRxm8QdhnT2JqfNL-Ydy2qnzLGnXm-lQDBh3MGvOEUirJ-mbHUFEe6Q2edtvrT4=s72-w640-h464-c" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-31.117791538385614 8.6503746355819686 72.30515953838561 149.275385364418</georss:box></entry><entry><id>tag:blogger.com,1999:blog-6755409718803839197.post-8538703188705834517</id><published>2021-07-13T12:55:00.015+05:30</published><updated>2022-01-11T23:46:18.307+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="sorting"/><title type='text'>Merge Sort Algorithm in C++ and Python</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXpbhNO0goLm4vT5nQgdYLmG4snY4C8QxCh-LrkFmrDMD2U-Q4nvsQ-YxWjXfztGp6GnhOvkLqjwRNFsToJcQ33QMOHs62uoMg44SLQsC1NK8KvOESuuYJ3wiiiCriTg32w4rlupqcPnM/&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Merge Sort Algorithm in C++ and Python&quot; data-original-height=&quot;1300&quot; data-original-width=&quot;1733&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXpbhNO0goLm4vT5nQgdYLmG4snY4C8QxCh-LrkFmrDMD2U-Q4nvsQ-YxWjXfztGp6GnhOvkLqjwRNFsToJcQ33QMOHs62uoMg44SLQsC1NK8KvOESuuYJ3wiiiCriTg32w4rlupqcPnM/w640-h480/image.png&quot; title=&quot;Merge Sort Algorithm in C++ and Python&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: #273239; font-family: georgia; font-size: 17px; letter-spacing: 0.162px;&quot;&gt;Like&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;QuickSort&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #273239; font-family: georgia; font-size: 17px; letter-spacing: 0.162px;&quot;&gt;, Merge Sort is a&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Divide and Conquer&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #273239; font-family: georgia; font-size: 17px; letter-spacing: 0.162px;&quot;&gt;&amp;nbsp;algorithm. It divides the input array into two halves array, calls itself for the two halves, and then merges the two sorted halves.&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;background-color: white; border: 0px; box-sizing: border-box; color: #273239; font-size: 17px; letter-spacing: 0.162px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;span&gt;The &lt;/span&gt;&lt;span&gt;Merge()&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt; function&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;background-color: white; color: #273239; font-family: georgia; font-size: 17px; letter-spacing: 0.162px;&quot;&gt;&amp;nbsp;is used for merging two halves.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: #273239; font-size: 17px; letter-spacing: 0.162px;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;The&lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;b&gt;Merge(array, start, mid, end)&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt; is a key process that assumes that &lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;b&gt;array[start..mid]&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt; and &lt;/span&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;b&gt;array[mid+1..end]&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt; are sorted and merges the two sorted sub-arrays into one. See the following &lt;/span&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;C++&lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt; and &lt;/span&gt;&lt;span style=&quot;font-family: Source Code Pro;&quot;&gt;python &lt;/span&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;implementation for details.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #273239; font-family: georgia; font-size: large;&quot;&gt;&lt;span style=&quot;letter-spacing: 0.162px;&quot;&gt;&lt;b style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #202124; font-size: medium; letter-spacing: normal; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Read Also:&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithms-in-cpp.html&quot; style=&quot;background: 0px 0px; border: 0px; color: #ff4545; outline: 0px; padding: 0px; text-decoration-line: none; transition: color 0.17s ease 0s; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;All Sorting Algorithm In C++&lt;/a&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #273239; font-family: georgia; font-size: large;&quot;&gt;&lt;span style=&quot;letter-spacing: 0.162px;&quot;&gt;&lt;i&gt;Input:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&amp;nbsp;=&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;78&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;};&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #273239; font-family: georgia; font-size: large;&quot;&gt;&lt;span style=&quot;letter-spacing: 0.162px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #273239; font-family: georgia; font-size: large;&quot;&gt;&lt;span style=&quot;letter-spacing: 0.162px;&quot;&gt;&lt;i&gt;output:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;sorted&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;78&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #273239; font-family: georgia; font-size: large;&quot;&gt;&lt;span style=&quot;font-weight: normal; letter-spacing: 0.162px;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #273239; font-family: georgia; font-size: large;&quot;&gt;&lt;span style=&quot;letter-spacing: 0.162px;&quot;&gt;&lt;i&gt;Explanation:&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: #273239; font-size: 17px; letter-spacing: 0.162px;&quot;&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;mergeSort(array[], start, end):&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; color: #273239; font-size: 17px; letter-spacing: 0.162px;&quot;&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;If start &amp;lt; end:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #273239; font-size: 12pt; letter-spacing: 0.162px;&quot;&gt;&lt;i&gt;Find the middle point to divide the array into two halves:&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #273239; font-family: Consolas; font-size: 12pt; letter-spacing: 0.162px;&quot;&gt;middle mid = start+ (end - start) / 2&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #273239; font-size: 12pt; letter-spacing: 0.162px; white-space: pre;&quot;&gt;&lt;i&gt;Call mergeSort for the first half:&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #273239; font-family: Consolas; font-size: 12pt; letter-spacing: 0.162px;&quot;&gt;Call mergeSort(array, start, mid)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #273239; font-size: 12pt; letter-spacing: 0.162px; white-space: pre;&quot;&gt;&lt;i&gt;Call mergeSort for the second half:&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #273239; font-family: Consolas; font-size: 12pt; letter-spacing: 0.162px; white-space: pre;&quot;&gt;Call mergeSort(array, mid+1, end)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: Consolas;&quot;&gt;&lt;span style=&quot;color: #273239; font-size: 12pt; letter-spacing: 0.162px; white-space: pre;&quot;&gt;&lt;i&gt;Merge the two halves sorted in steps 2 and 3:&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #273239; font-family: Consolas; font-size: 12pt; letter-spacing: 0.162px; white-space: pre;&quot;&gt;Call merge(array,start, mid, end)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #273239; font-family: Consolas, monospace;&quot;&gt;&lt;span style=&quot;letter-spacing: 0.162px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #273239;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-family: Consolas, monospace; text-align: center;&quot;&gt;&lt;a href=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Merge-sort-example-300px.gif/220px-Merge-sort-example-300px.gif&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;132&quot; data-original-width=&quot;220&quot; height=&quot;152&quot; src=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Merge-sort-example-300px.gif/220px-Merge-sort-example-300px.gif&quot; title=&quot;this is image from wikipedia&quot; width=&quot;253&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;b&gt;&lt;i&gt;this is an image from Wikipedia&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-family: Consolas, monospace; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; color: #2c3e50; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;Implementation&lt;/span&gt;&lt;span style=&quot;font-family: georgia; font-weight: 500;&quot;&gt;:&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h2&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: large;&quot;&gt;C++&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #2c3e50; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;&quot;&gt;Implementation&lt;/span&gt;:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//c++&amp;nbsp;program&amp;nbsp;for&amp;nbsp;merge&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;Merge&amp;nbsp;to&amp;nbsp;subarray&amp;nbsp;of&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;first_array&amp;nbsp;=&amp;nbsp;array[start..mid]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;second_array&amp;nbsp;=&amp;nbsp;array[mid+1..end]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Merge&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;creating&amp;nbsp;to&amp;nbsp;temp&amp;nbsp;subarray&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;copy&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;copy&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;index&amp;nbsp;reference&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;for&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;for&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;for&amp;nbsp;main&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_1&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;//&amp;nbsp;size&amp;nbsp;of&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_2&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;//&amp;nbsp;size&amp;nbsp;of&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;merge&amp;nbsp;subarray&amp;nbsp;first_array&amp;nbsp;and&amp;nbsp;second_array&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;into&amp;nbsp;array[start..end]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_1&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_2&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;&amp;lt;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;copy&amp;nbsp;remaining&amp;nbsp;element&amp;nbsp;of&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;first_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;copy&amp;nbsp;remaining&amp;nbsp;element&amp;nbsp;of&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;size_2&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;second_array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;main_i&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;main&amp;nbsp;merge&amp;nbsp;Sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;mergeSort&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;finding&amp;nbsp;mid&amp;nbsp;point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;&amp;nbsp;+&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;)&amp;nbsp;/&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;divide&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;mergeSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;mergeSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;);&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;conquer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Merge&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;//&amp;nbsp;driver&amp;nbsp;code&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;declaring&amp;nbsp;&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&amp;nbsp;=&amp;nbsp;{&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;78&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;};&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;size&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;mergeSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;array&amp;nbsp;is&amp;nbsp;sorted&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array:&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i&gt;Python Implementation:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 24px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;python&amp;nbsp;program&amp;nbsp;for&amp;nbsp;merge&amp;nbsp;sort&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;Merge&amp;nbsp;to&amp;nbsp;subarray&amp;nbsp;of&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;first_array&amp;nbsp;=&amp;nbsp;array[start..mid]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;second_array&amp;nbsp;=&amp;nbsp;array[mid+1..end]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;Merge&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;mid&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;creating&amp;nbsp;to&amp;nbsp;temp&amp;nbsp;subarray&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;first_array&amp;nbsp;=&amp;nbsp;[]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;second_array&amp;nbsp;=&amp;nbsp;[]&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;copy&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(start,&amp;nbsp;mid+&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;first_array.append(array[i])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;copy&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(mid&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;end+&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;second_array.append(array[i])&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;index&amp;nbsp;reference&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;for&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;for&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;main_i&amp;nbsp;=&amp;nbsp;start&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;for&amp;nbsp;main&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size_1&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(first_array)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;size&amp;nbsp;of&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;size_2&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(second_array)&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;size&amp;nbsp;of&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;merge&amp;nbsp;subarray&amp;nbsp;first_array&amp;nbsp;and&amp;nbsp;second_array&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;into&amp;nbsp;array[start..end]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&amp;lt;&amp;nbsp;size_1&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;and&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;size_2:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;first_array[i]&amp;nbsp;&amp;lt;=&amp;nbsp;second_array[j]:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;array[main_i]&amp;nbsp;=&amp;nbsp;first_array[i]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;array[main_i]&amp;nbsp;=&amp;nbsp;second_array[j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;main_i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;copy&amp;nbsp;remaining&amp;nbsp;element&amp;nbsp;of&amp;nbsp;first_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&amp;lt;&amp;nbsp;size_1:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;array[main_i]&amp;nbsp;=&amp;nbsp;first_array[i]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;main_i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;copy&amp;nbsp;remaining&amp;nbsp;element&amp;nbsp;of&amp;nbsp;second_array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&amp;lt;&amp;nbsp;size_2:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;array[main_i]&amp;nbsp;=&amp;nbsp;second_array[j]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;main_i&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;main&amp;nbsp;merge&amp;nbsp;Sort&amp;nbsp;function&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;def&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;mergeSort&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;array&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;start&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;start&amp;nbsp;&amp;gt;=&amp;nbsp;end:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;finding&amp;nbsp;mid&amp;nbsp;point&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mid&amp;nbsp;=&amp;nbsp;start&amp;nbsp;+&amp;nbsp;(end&amp;nbsp;-&amp;nbsp;start)&amp;nbsp;//&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;divide&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mergeSort(array,&amp;nbsp;start,&amp;nbsp;mid)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mergeSort(array,&amp;nbsp;mid&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;end)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;conquer&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Merge(array,&amp;nbsp;start,&amp;nbsp;mid,&amp;nbsp;end)&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;driver&amp;nbsp;code&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;declaring&amp;nbsp;&amp;nbsp;array&lt;/span&gt;&lt;/div&gt;&lt;div&gt;array&amp;nbsp;=&amp;nbsp;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;78&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;]&lt;/div&gt;&lt;div&gt;n&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;len&lt;/span&gt;(array)&lt;/div&gt;&lt;div&gt;mergeSort(array,&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;n&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;#&amp;nbsp;array&amp;nbsp;is&amp;nbsp;sorted&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;sorted&amp;nbsp;array:&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;range&lt;/span&gt;(n):&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;(array[i],&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;end&lt;/span&gt;=&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;print&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: georgia; font-size: medium;&quot;&gt;&lt;i style=&quot;font-weight: normal;&quot;&gt;Output:&lt;/i&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; overflow-x: scroll;&quot;&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 18px; line-height: 24px; white-space: pre;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;sorted&lt;/span&gt;&amp;nbsp;array:&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;9&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;78&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; font-family: Consolas, monospace; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 24px; white-space: pre;&quot;&gt;&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: Merriweather; font-size: 15px; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: Merriweather; font-size: 15px; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px rgb(255, 255, 255); border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i&gt;Time Complexity: &lt;span style=&quot;font-weight: normal;&quot;&gt;O(N*log N)&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: Merriweather; font-size: 15px; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background-color: white;&quot;&gt;Auxiliary Space: &lt;span style=&quot;font-weight: normal;&quot;&gt;O(N)&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;strong style=&quot;background: 0px 0px white; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #656565; font-family: Roboto, sans-serif; font-size: 15px; font-weight: 400; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;b style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;i style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; color: #202124; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Read Also:&lt;/span&gt;&lt;a href=&quot;https://algorithmdotcpp.blogspot.com/2021/07/all-sorting-algorithm-implementation-in-python.html&quot; style=&quot;background: 0px 0px; border: 0px; color: #ff4545; outline: 0px; padding: 0px; text-decoration-line: none; transition: color 0.17s ease 0s; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; color: red; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background: 0px 0px; border: 0px; outline: 0px; padding: 0px; transition-duration: 0.17s; transition-property: color; vertical-align: baseline;&quot;&gt;All Sorting Algorithm In&amp;nbsp;&lt;/span&gt;&lt;/span&gt;python&lt;/span&gt;&lt;/a&gt;&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; font-family: georgia; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;p style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px 0px; background-repeat: initial; background-size: initial; border: 0px; color: #656565; font-family: Roboto, sans-serif; font-size: 15px; font-weight: 400; outline: 0px; padding: 0px; vertical-align: baseline; white-space: normal;&quot;&gt;&lt;/p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='https://algorithmdotcpp.blogspot.com/feeds/8538703188705834517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/merge-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8538703188705834517'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6755409718803839197/posts/default/8538703188705834517'/><link rel='alternate' type='text/html' href='https://algorithmdotcpp.blogspot.com/2021/07/merge-sort.html' title='Merge Sort Algorithm in C++ and Python'/><author><name>deep gajjar</name><uri>http://www.blogger.com/profile/15867439779175441337</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXpbhNO0goLm4vT5nQgdYLmG4snY4C8QxCh-LrkFmrDMD2U-Q4nvsQ-YxWjXfztGp6GnhOvkLqjwRNFsToJcQ33QMOHs62uoMg44SLQsC1NK8KvOESuuYJ3wiiiCriTg32w4rlupqcPnM/s72-w640-h480-c/image.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-59.074234918199551 -61.66212 90 -140.41212000000002</georss:box></entry></feed>